How to Fix nginx 502 Bad Gateway in Under 5 Minutes
How to Fix nginx 502 Bad Gateway in Under 5 Minutes You see this in your browser and your stomach drops: 502 Bad Gateway nginx/1.24.0 Or in your logs: 2024/01/15 03:42:11 [error] 1234#1234: *1 conn...

Source: DEV Community
How to Fix nginx 502 Bad Gateway in Under 5 Minutes You see this in your browser and your stomach drops: 502 Bad Gateway nginx/1.24.0 Or in your logs: 2024/01/15 03:42:11 [error] 1234#1234: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 203.0.113.5, server: yourdomain.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "yourdomain.com" Here's exactly what this means and how to fix it. What nginx 502 Actually Means 502 is NOT an nginx problem. nginx is fine. The problem is that nginx is trying to forward your request to your backend app (Node, Python, Rails, etc.) — and that app isn't responding. nginx is the middleman. Your app is dead. Step 1: Check if Your App is Running # Check if your Node/Python/whatever process is alive ps aux | grep node ps aux | grep python ps aux | grep gunicorn # Or check what's listening on your port ss -tlnp | grep :3000 If nothing is listening on port 3000 (or whatever your upstream is), your app c