net::ERR_CONNECTION_CLOSED error at Chrome with HTTP2.0 + Nginx

11,524

This is a workaround, not a solution to the problem. This error was happening to me in chrome when using nginx with http2 enabled.

I was able to disable http2 in nginx (or rather simply removed the option that enabled it).

I changed:

  server {
      listen 443 http2 ssl;
      listen [::]:443 http2 ssl;

to:

  server {
      listen 443 ssl;
      listen [::]:443 ssl;

After that, chrome worked fine with nginx.

What was especially weird about my issue was that it only happened when I passed large headers, over about 500 bytes. At all other times, chrome/ngnx behaved themselves. The entire time, curl was also working fine hitting my endpoints. Additionally, chrome and all other browsers I tested worked fine when I bypassed nginx to hit the endpoints directly.

From things that I have seen, I suspect that this is an issue with ALPN. Perhaps it was because my openssl version was outdated. It was easier to downgrade to http 1.1 than to look into that possibility though.

Share:
11,524
Admin
Author by

Admin

Updated on August 15, 2022

Comments

  • Admin
    Admin almost 2 years

    How to handle net::ERR_CONNECTION_CLOSED error in Google Chrome (v.51.0) when I try POST images on server (with jQuery or Dropzone.js) by https.

    Firefox work great on http and https. Chrome only http. Everything without file uploading works fine on Chrome+HTTPS. I'm getting this error after php timeout ends:

    dropzone.min.js:1 POST https://{example.com}/images/upload net::ERR_CONNECTION_CLOSED
    

    No other messages. Nothing at PHP and Nginx logs.

    My server: PHP 7.0.9 + Nginx 1.10 + Ubuntu Server 16.04 + HTTP2.0 with SSL cert by Comodo.

    UPDATED

    I found the problem and solution.

  • spice
    spice over 5 years
    Having exactly the same issue here. Chrome is crapping out with large uploads when HTTP2 is enabled. Is there a "proper" solution for this?
  • Jack Davidson
    Jack Davidson over 5 years
    @spice none that I know of. I looked for a long time and this was the best I could come up with or find on the internet. Looking back, since all other major browsers seem to work fine, its probably a chrome bug. So the only true solution would be to fix chrome/chromium.
  • spice
    spice over 5 years
    It does seem to only be relevant to Chrome and HTTP/2. I've just posted the solution that worked for me below. It's not exactly the answer for your specific situation but I found your question while I was trying to figure this out so hopefully others may find it helpful.