By gouskova
Trying to deploy a Django/Nginx/Gunicorn project, I cannot resolve a 502 Bad Gateway issue. Looking at nginx logs, I see “104: unknown error” and “111: unknown error”-- which seems kind of uninformative. How do I debug this further?
p.s. the most recent error recorded goes like this: "*28 connect() to unix:/home/username/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: IP_ADDRESS, server: _, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/username/gunicorn.socket:/”, host: “MY_DROPLET_IP_ADDRESS:80” "
I can post some details of my gunicorn.service and nginx configuration if this isn’t enough… been fighting with this for hours, coming from Apache2 and WSGI it’s a lot more moving pieces.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
Sounds like your Gunicorn socket isn’t being created or Nginx isn’t pointing at it correctly.
This DigitalOcean guide on setting up Django with Postgres, Nginx & Gunicorn walks through creating the systemd socket, service files, and Nginx proxy config, double check those steps:
Look into your Gunicorn systemd
logs (e.g. journalctl -u gunicorn.socket
) and your Nginx error logs, you’ll usually find clues like missing socket files, permission issues, or path problems.
If everything matches the tutorial but it’s still failing, post your gunicorn.socket
, gunicorn.service
, and Nginx site config. That way the community could advise you better.
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.