Question

Deploy Django 1.7 Application (using DigitalOcean quick start tutorial) - Error 500 =(

Hello, everyone!

I tried to follow this tutorial link, but it hasn’t worked for me. =(

I know that error 500 should be an application error, but, the application works fine on my computer.

This is nginx configs

upstream app_server {
    server 127.0.0.1:9000 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/agenciafacilonline/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/agenciafacilonline/agenciafacilonline/static;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://104.131.104.172/;
    }
}

This is my gunicorn configs

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=agenciafacilonline \
    --pythonpath=agenciafacilonline \
    --bind=0.0.0.0:9000 \
    --config /etc/gunicorn.d/gunicorn.py \
    django_project.wsgi:application

Do I need to do anything more?

Many thanks

@HigorSilvaRosa

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I had a similar problem, and all logs were empty too !!

The problem with me was that I’m using environment variables in code, that was declared in .bashrc but wasn’t read ! The solution was to declare those environment variable inside /etc/init/gunicorn.conf file.

env KEY=VALUE

And it works :) This may help you, or if not check init files reference It may be more useful

The errors mean that whatever should be running on port 9000 isn’t running, which is gunicorn in this case.

Check gunicorn’s error log, are there any errors?

sudo tail -30 /var/log/upstart/gunicorn.log

Unrelated: I would replace --bind=0.0.0.0:9000 with --bind=127.0.0.1:9000 so that gunicorn itself can’t be accessed externally (you want everything to go through nginx first).