Gunicorn`无法连接到('ind',8000)` - Django,EC2,Nginx

时间:2015-11-20 19:36:28

标签: django amazon-web-services nginx amazon-ec2 gunicorn

这似乎在今天早些时候工作,我不知道发生了什么变化。我对部署非常缺乏经验,所以这可能是我最缺失的最简单的事情。

我在EC2上使用默认的Amazon Linux映像。在新创建的实例中,输入的命令如下:

yum search python34 #Amazon Linux doesn't have 3.5 yet
sudo yum install python34-virtualenv
sudo alternatives --set python /usr/bin/python3.4
virtualenv-3.4 env
sudo pip install --upgrade pip
hash -r
sudo ln -s /usr/local/bin/pip /usr/bin/pip

sudo pip install django
django-admin.py startproject MyApp
cd MyApp
python manage.py runserver #This gives me ERR_CONNECTION_REFUSED in Chrome on port 8000, but worked earlier

sudo yum install nginx
sudo service nginx start #This works, I'm able to see the default page on default port
sudo service nginx stop

sudo pip install gunicorn
gunicorn -bind 0.0.0.0:8000 MyApp.wsgi:application #This doesn't even start

以下是上一个命令的结果:

[ec2-user@ip-172-31-48-233 MyApp]$ gunicorn -bind 0.0.0.0:8000 MyApp.wsgi:application
[2015-11-20 19:16:36 +0000] [2547] [INFO] Starting gunicorn 19.3.0
[2015-11-20 19:16:36 +0000] [2547] [ERROR] Retrying in 1 second.
[2015-11-20 19:16:37 +0000] [2547] [ERROR] Retrying in 1 second.
[2015-11-20 19:16:38 +0000] [2547] [ERROR] Retrying in 1 second.
[2015-11-20 19:16:39 +0000] [2547] [ERROR] Retrying in 1 second.
[2015-11-20 19:16:40 +0000] [2547] [ERROR] Retrying in 1 second.
[2015-11-20 19:16:41 +0000] [2547] [ERROR] Can't connect to ('ind', 8000)
[ec2-user@ip-172-31-48-233 MyApp]$

我现在很迷茫,找不到太多最新资源来指导我完成这个过程的细节。任何帮助将不胜感激,谢谢。

3 个答案:

答案 0 :(得分:5)

参数为-b--bind,而不是-bind

答案 1 :(得分:1)

无论如何,我找到了这个问题的根源。当在具有gunicorn运行的shell中时,使用ctrl c而不是ctrl z退出。之后没有寻找pid关闭。 祝你好运Overflowers

答案 2 :(得分:0)

这对我有用:

pgrep gunicorn

它会返回你的pid,就像这样:

23716
23718

现在使用以下命令杀死其中任何一个:

kill 23716

您可以使用 pgrep gunicorn 重新检查它是否仍在运行并相应地终止。