Gunicorn - Can't Access Django Project (Browser Times Out)

◇◆丶佛笑我妖孽 提交于 2019-12-23 15:44:02

问题


Using AWS and Gunicorn, my Django site is accessible and fully functional if I spin up the Django's built-in server, but I can't access it through Gunicorn.

If I try:

gunicorn MyApp.wsgi

It seems to start up:

[2015-11-18 17:53:30 +0000] [18752] [INFO] Starting gunicorn 19.3.0
[2015-11-18 17:53:30 +0000] [18752] [INFO] Listening at: http://0.0.0.0:8001 (18752)
[2015-11-18 17:53:30 +0000] [18752] [INFO] Using worker: sync
[2015-11-18 17:53:30 +0000] [18755] [INFO] Booting worker with pid: 18755

But the browser just returns the Nginx splash page at the basic URL/IP address and times out when attempting to visit <url>:8001 or <ip_address>:8001.

I get the same result if I run:

gunicorn MyApp.wsgi:application --bind 0.0.0.0:8001

EDIT: If I try the same command with the specific URL in place of 0.0.0.0 it outputs the following:

[2015-11-18 18:24:17 +0000] [18902] [INFO] Starting gunicorn 19.3.0
[2015-11-18 18:24:17 +0000] [18902] [ERROR] Retrying in 1 second.
[2015-11-18 18:24:18 +0000] [18902] [ERROR] Retrying in 1 second.
[2015-11-18 18:24:19 +0000] [18902] [ERROR] Retrying in 1 second.
[2015-11-18 18:24:20 +0000] [18902] [ERROR] Retrying in 1 second.
[2015-11-18 18:24:21 +0000] [18902] [ERROR] Retrying in 1 second.
[2015-11-18 18:24:22 +0000] [18902] [ERROR] Can't connect to ('myurl.xyz', 8001)

If I use the server's IP address, I see:

[2015-11-18 18:26:22 +0000] [18911] [INFO] Starting gunicorn 19.3.0
[2015-11-18 18:26:22 +0000] [18911] [ERROR] Invalid address: ('<my_ip>', 8001)

I spent 3 days unsuccessfully trying to get uWSGI to work and I'm on day 2 with Gunicorn and I can't seem to get past this point with either. None of the docs or tutorials specify what to do if this first step doesn't work. I'm very new at this, perhaps there is something simple that I'm overlooking that everyone else just assumes would be taken care of?

All relevant IP addresses and urls are set correctly in the ALLOWED_HOSTS portion of Django's settings module.


回答1:


As Daniel Roseman indicated, Amazon doesn't seem to allow me to do what I was trying to do here without additional configuration.

I took the advice and configured Nginx and now I am able to use

gunicorn MyApp.wsgi:application --bind=172.31.21.65:8000

to spin it up.



来源:https://stackoverflow.com/questions/33787092/gunicorn-cant-access-django-project-browser-times-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!