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

Gunicorn `Can't connect to ('ind', 8000)` - Django, EC2, Nginx

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

我在 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]$

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

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

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

这对我有用:

pgrep gunicorn

它会 return 你 pid,像这样:

23716
23718

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

kill 23716

如果它仍然是 运行,您可以使用 pgrep gunicorn 重新检查并相应地杀死它。