Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to set up a development environment using Gunicorn and NGINX.

While following this tutorial: http://ijcdigital.com/blog/django-gunicorn-and-nginx-setup/

I get the following error:

(WebApp)sl@cker:~/MyApps/WebApp$ gunicorn_django --bind=127.0.0.1:8001
2012-07-12 14:04:30 [5997] [INFO] Starting gunicorn 0.14.5
2012-07-12 14:04:30 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001)
2012-07-12 14:04:30 [5997] [ERROR] Retrying in 1 second.
2012-07-12 14:04:31 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001)
2012-07-12 14:04:31 [5997] [ERROR] Retrying in 1 second.
2012-07-12 14:04:32 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001)
2012-07-12 14:04:32 [5997] [ERROR] Retrying in 1 second.
2012-07-12 14:04:33 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001)
2012-07-12 14:04:33 [5997] [ERROR] Retrying in 1 second.
2012-07-12 14:04:34 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001)
2012-07-12 14:04:34 [5997] [ERROR] Retrying in 1 second.
2012-07-12 14:04:35 [5997] [ERROR] Can't connect to ('127.0.0.1', 8001)

My webapp.sh file looks like this:

#!/bin/bash
set -e
LOGFILE=/home/sl/MyApps/WebApp/logs/webapp.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
# user/group to run as
USER=sl
GROUP=sl
ADDRESS=127.0.0.1:8001
cd /home/sl/MyApp/WebApp
source /home/sl/VirtualEnvs/WebApp/bin/activate
test -d $LOGDIR || mkdir -p $LOGDIR
exec gunicorn_django -w $NUM_WORKERS --bind=$ADDRESS \
  --user=$USER --group=$GROUP --log-level=debug \
  --log-file=$LOGFILE 2>>$LOGFILE

When browsing to http://127.0.0.1:8001/, the "It worked! Congratulations on your first Django-powered page." is displayed correctly.

Can I just leave it like this and continue the tutorial or did I do something wrong here?

share|improve this question

2 Answers 2

I know this is an old question, but I think I have an alternative answer to this.

I was experiencing the same problem. The log would show gunicorn trying to start and then lots of entries showing the port is already in use.

I realised, that I had entered the virtualenv BEFORE running my script. Which then activated the virtualenv again. This seems to run the script twice on the trot. As soon as I deactivated my console virtualenv and let the script handle the virtualenv itself, everything worked as expected.

Hope this helps someone else.

share|improve this answer

It sounds like you're running the debug server manage.py runserver and then trying to start gunicorn which will try to use the same port.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.