davidtgq
davidtgq

Reputation: 4000

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

This seemed to be working earlier today, I don't know what changed. I'm very inexperienced with deployment, so it could be the simplest thing that I'm missing.

I'm using the default Amazon Linux image on EC2. In a freshly created instance, here are the commands entered:

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

Here are the results from the last command:

[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]$

I'm quite lost right now, couldn't find much up-to-date resources to guide me through the details of this process. Any help would be appreciated, thanks.

Upvotes: 1

Views: 2803

Answers (3)

Priyanshu Singh
Priyanshu Singh

Reputation: 71

This worked for me:

pgrep gunicorn

It will return you the pid, something like this:

23716
23718

Now kill any one of them using:

kill 23716

You can recheck using pgrep gunicorn if it's still running and kill accordingly.

Upvotes: 0

Matt Raye
Matt Raye

Reputation: 11

I found the root of this problem, for me anyway. When in the shell that has gunicorn running, exit with ctrl c instead of ctrl z. After that no hunting for pid's to close. good luck Overflowers

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599450

The parameter is -b or --bind, not -bind.

Upvotes: 14

Related Questions