What causes 502 bad gateway when using Nginx reverse proxy and proxy_pass?
#1
I’m trying to set up a reverse proxy with Nginx on my home server to access a few self-hosted services, but I keep getting 502 Bad Gateway errors. My config file seems correct, pointing to the local port where the app is running, and the service is definitely up. I’m wondering if the issue is with my understanding of how the proxy_pass directive actually communicates with the backend service.
Reply
#2
502 usually means nginx can’t talk to the upstream or the upstream dropped the connection. If the app is actually listening on the port, something between nginx and the app is failing—network, binding, or protocol mismatch are common culprits I’ve run into.
Reply
#3
Double-check the protocol match. If the upstream is http but you’re somehow sending https, nginx will bail with that bad gateway vibe. I had that scramble once and it was just a misconfigured scheme.
Reply
#4
I did a quick check by curling the backend from the nginx host to see what it answers. Also I remember changing proxy_pass from localhost to 127.0.0.1 was a tiny but annoying fix that resolved it for me once, even though the port stayed the same.
Reply
#5
I keep wondering if the real problem is something else, like a timeout or a misconfigured upstream header, and maybe we're chasing the wrong thing entirely.
Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump: