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

I'm trying to deploy my Django app for the first time on a Digital Ocean VPS. I've used their Django droplet which setup things like this except I'm not using a virtual environment.

After adding my code and changing a few things, if I run gunicorn directly from the command line, the site loads.

However, if I run gunicorn as a service sudo service gunicorn start, I just get an 500 "Internal Service Error". There is no error in the nginx log file. The gunicorn log file does not exist.

Here is the command I run that works (run from the /home/django directory):

gunicorn --pythonpath=myproject --bind=0.0.0.0:9000 --config /etc/gunicorn.d/gunicorn.py myproject.wsgi:application

Here is the /etc/init/gunicorn.conf file:

description "Gunicorn daemon for Django project"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]

# If the process quits unexpectedly trigger a respawn
respawn

setuid django
setgid django
chdir /home/django

exec gunicorn \
    --name=myproject \
    --pythonpath=myproject \
    --bind=0.0.0.0:9000 \
    --config /etc/gunicorn.d/gunicorn.py \
    myproject.wsgi:application

I'm new to gunicorn and nginx so this is really stumping me.

share|improve this question

1 Answer 1

Internal Server Error (HTTP 500) usually indicates that there is a problem with your code, not the Web Server application.

Have you set up logging?
You should log all 500 errors to a file in your django project, so that you can see why the error is occurring.

You can also try switching on Debug mode, which should tell you why the application is failing.

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.