简体   繁体   中英

Django on Digitalocean with Python and Gunicorn throws 500 error no matter the Debug settings

I'm REALLY confused. Ive been using the same settings for years and they have worked great... until today.

Setup: Django on Gunicorn with NGINX on Digitalocean Python 3

Anytime I go to a URL it looks liek the 500 error is being triggered and then the 500.html template is displayed. But this is happening regardless of the Debug settings. Additionally, there is nothing that is being written to the Gunicorn errors. The only error I'm getting is a 404 on the template directory.

As a sanity check, here is some sample configurations that I'm using.

NGINX Location:

root /home/myname/myrepoproject;

error_page 500 502 503 504 /500.html;
location = /500.html {
    root /home/myname/myrepoproject/myproject/app/templates;
}

NGINX Error:

2018/03/26 17:09:14 [crit] 3267#3267: *35 connect() to unix:/home/myname/myproject/myproject.sock failed (2: No such file or directory) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: ZZZ.ZZZ.ZZZ.ZZZ, request: "GET /500.html/ HTTP/1.1", upstream: "http://unix:/home/myname/myproject/myproject.sock:/500.html/", host: "arecord.domain.name"

Gunicorn ExecStart:

ExecStart=/home/myname/.virtualenvs/myve/bin/gunicorn --error-logfile ~/logs/gunicorn/gunicorn-errors.log --workers 3 --bind unix:/home/myname/myve/myproject.sock production

The static and upload directories work.

Any troubleshooting ideas welcome.

From the errors you posted it looks like your nginx and gunicorn configs do not have the same location set of the socket so they fail to communicate.

Nginx is looking at unix:/home/myname/myproject/myproject.sock but your gunicorn command line says --bind unix:/home/myname/myve/myproject.sock .

Make them match and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM