Reputation: 3539
I'm trying to use Django with virtualenv. I actually got the Django hello world webpage to display with 127.0.0.1:8001. Later I had to do some minor tweaks and now its giving me this error when I try to launch it again (I ctrl-Z from the previous working gunicorn session so I don't think it is because of that).
user myenv # /opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myProject.wsgi
2013-11-02 08:26:37 [27880] [INFO] Starting gunicorn 18.0
2013-11-02 08:26:37 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:37 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:38 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:38 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:39 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:39 [27880] [ERROR] Retrying in 1 second.
^C2013-11-02 08:26:40 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:40 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:41 [27880] [ERROR] Connection in use: ('127.0.0.1', 8001)
2013-11-02 08:26:41 [27880] [ERROR] Retrying in 1 second.
2013-11-02 08:26:42 [27880] [ERROR] Can't connect to ('127.0.0.1', 8001)
user myenv #
Other commands I recently used include:
python manage.py syncdb
python manage.py startapp polls
I did 'killall python' to make sure they were not the cause.
gunicorn_config.py:
command = '/opt/myenv/bin/gunicorn'
pythonpath = '/opt/myenv/myProject
workers = 1
user = 'tim'
myProject.wsgi:
import os
# os.environ["DJANGO_SETTINGS_MODULE"] = "myProject.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myProject.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Upvotes: 1
Views: 2737
Reputation: 3517
The error Connection in use: ...
basically means that the port is still in use even though you exited the server. You need to find who is currently using the port and turn them off. This command can help you find who is there:
$ sudo netstat -nlp | grep :80
Then you can sudo kill that process:
sudo fuser -k 8000/tcp
You should be able to restart gunicorn
.
Upvotes: 1
Reputation: 39
The port 8000 was probably bound and thus unavailable for the connection.
Upvotes: 0
Reputation: 25052
ctrl+z
halts the process, but does not close it. In consequence it does not release its ports. You can bring the process back with fg
and then close it properly using ctrl+c
.
Upvotes: 3