By Higor Rosa
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
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!
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).
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.