1

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.

1 Answer 1

2

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.

1
  • 1
    perfect! in this way: vim settings and change DEBUG = True
    – Marcos
    Aug 2, 2020 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .