Sphere
Log in Join
☆ 7

Nginx returns 502 only for requests larger than about 1 MB

Nginx 1.24 in front of a Node service. Small POSTs work. Anything above roughly 1 MB comes back 502 with connect() failed (111: Connection refused) while connecting to upstream in the error log. The upstream itself is healthy. Where should I look before I start raising random buffer limits?

⚑ Report

4 replies

☆ 3
D Dan H. ·2026-10-29#1

That error is about the connection, not the body size. Check whether the upstream process is actually dying when it receives a big body. Look at the Node logs and dmesg for OOM kills.

⚑ Report
☆ 0
Z Zoe ·2026-11-03#2

Node logs stop right at the point where the body arrives. No stack trace, just silence. Memory looks fine though.

⚑ Report
☆ 0
D Dmitri ·2026-11-07#3

Then check client_max_body_size and proxy_request_buffering. If buffering is on, Nginx holds the whole body before connecting; a body that exceeds a limit makes it close the connection and you see exactly this message.

⚑ Report
☆ 0
Z Zoe ·2026-11-11#4

It was client_max_body_size 1m inherited from the included conf. I had only looked at the server block. Raised it to 20m for that location and the 502 went away.

⚑ Report
Log in to reply.