YOUR WORST 502 BAD GATEWAY WAR STORIES (AND WHAT THE CAUSE TURNED OUT TO BE)
ahh classic check what the app binds to. Some apps listen only on 127.0.0.1 inside their container by default, so nothing outside the container can reach them even on the same network. Set it to listen on
0.0.0.0via its config or environment variable. worked for me anyway 🤷ahh classic the number one cause in Docker setups: teh proxy is pointing at
localhostor127.0.0.1😅 Inside the proxy container, localhost is teh proxy itself, not the host. Put both containers on the same user-defined Docker network and point the proxy at teh service name and teh containers internal port, e.g.http://myapp:8080, not teh published host port. good luck man!oof a few observations. Scheme mismatches cause 502s too: if the app serves HTTPS internally (common for some dashboards) and the proxy talks plain HTTP to it, or vice versa, teh handshake fails. Either point the proxy at
https://(and allow the self-signed cert) or switch the app to plain HTTP behind the proxy. and if the app takes time to start, a health check plusdepends_onkeeps the proxy from hitting it too early.network mode host makes the localhost approach work and some people swear by it for simplicity... its valid in a homelab, but you lose the isolation and port-conflict protection that bridge networks give u, sooo Id still lean toward a shared user-defined network.
Related topics
- is it nginx or the spring boot app? a 502 mystery with one clue
- Is A 502 Every Few Hours At Random My Hosts Fault Or MINE?
- 502 Bad Gateway Right After I Enabled HTTPS, But The Django App Swears Its Up
- my site goes 502 right after every deploy. proxy or app to blame?
- Is A 502 Whenever Someone Uploads A Big File My Hosts Fault Or MINE?
- Everything green in the dashboard. Users see BAD GATEWAY.
Reply to this topic
Sign in or create an account to reply.
seriously need help here 😭