1GB File Upload Failure - 502 Bad Gateway

Hi @Everyone, My MERN stack doesn’t allow clients to upload more than 1GB files, while 800MB, 300M ,and 50MB file uploads worked correctly.

After uploading progress reaches100%, it immediately retrieves 502 Bad Gateway responses.

Here is the server log:

2022/03/03 14:54:15 [error] 2614707#2614707: *7 upstream prematurely closed connection while reading response header from upstream, client:, server:, request: “POST /api/modules/uploadFile HTTP/1.1”, upstream: “”, host: “”, referrer: “


    proxy_max_temp_file_size 0;
    proxy_connect_timeout 1800s;
    proxy_send_timeout 1800s;
    proxy_read_timeout 1800s;
    proxy_buffer_size 128k;
    proxy_buffers 128 256k;
    proxy_busy_buffers_size 256k;
    proxy_redirect off;
    proxy_request_buffering off;
    proxy_buffering off;


http {

    # Basic Settings

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 1800;
    types_hash_max_size 2048;
    client_max_body_size 4096M;
    fastcgi_read_timeout 1800s;
    client_body_timeout 1800s;
    client_header_timeout 1800s;
    # server_tokens off;


Could anyone recommend any solutions,please? Thank you

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
March 5, 2022


The Nginx configuration looks correct, according to the error that you’ve shared your Node backend service is closing the connection prematurely, do you see any errors in your Node application?



try to direct upload via ftp