is it nginx or the django app? a 502 mystery with one clue

502nginxreverse-proxy4 replies · 188 views · started
  1. i just moved our Django app to a new server and set up nginx as the reverse proxy. Every request returns:

    502 Bad Gateway

    502 Bad Gateway
    nginx
    

    The app logs show nothing, as if no request ever arrives. Firewall is open, teh process is running, port 5000 is listening. What on earth is nginx talking to?

    im used to deploying on a PaaS where this just works, sooo the proxy layer is new territory for me... could it be a perimssions thing, an address thing, or something Ive never even heard of?? any direction helps.

    rage

    2
  2. hmmm what exactly does /var/log/nginx/error.log say at teh moment of a 502?

    0 2 helpful
  3. lol same thing happened to me after deploys: if your process manager restarts teh app and nginx hits it during the gap, u'll see refused connections. use a graceful reload (pm2 reload, gunicorn HUP, a rolling restart) or put two instances behind teh upstream. hope that helps :)

    2 0 helpful
  4. oh ive been there lol start with the nginx error log, it tells you which kinda 502 it is:

    sudo tail -f /var/log/nginx/error.log
    

    connect() failed (111: Connection refused) means nothing listens where proxy_pass points. upstream prematurely closed connection means the app accepted and then dropped the request lol no live upstreams means all backends were marked down.

    3 2 helpful

Reply to this topic

Sign in or create an account to reply.