I'm trying to get my django project up and running on an aws ec2 instance. I'm using gunicorn with nginx, and I'm not really sure how I can tackle this problem. I've spent a couple hours on it already, including looking at other posts on this site.. but I'm still stuck. Here's what's wrong: Along with the 502 Bad Gateway, my nginx error logs keep giving me back this:
2015/07/17 08:32:32 [error] 8049#0: *18 connect() failed (111: Connection refused) while connecting to upstream, client: ip.ip.ip.ip, server: ip.ip.ip.ip, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "ec2-numbers.us-west-1.compute.amazonaws.com"
My /etc/nginx/sites-available/at_api.conf
looks like this (Is the indentation okay on this?):
server {
listen 80;
server_name ip.ip.ip.ip;
access_log /var/log/nginx/site_access.log;
error_log /var/log/nginx/site_error.log;
location /static/ {
alias /home/ubuntu/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}
This is my first time setting up my django project on ec2... so I'm not really sure if this is the right way to be doing this. Any tips?
p.s. I've seen another similar post saying that php-fpm
wasn't configured properly, but I'm using django, so I'm not using any php.
Edit: My at_api/gunicorn.conf.py
proc_name = "at_api"
bind = '127.0.0.1:8001'
loglevel = "error"
workers = 2
Edit 2: Netstat
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8463/nginx: worker
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
udp 0 0 0.0.0.0:10524 0.0.0.0:* -
udp6 0 0 :::21956 :::* -
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 8754 - /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 52566 - /var/run/supervisor.sock.8446
unix 2 [ ACC ] STREAM LISTENING 6691 - @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 9075 - /var/run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 35450 - /var/run/postgresql/.s.PGSQL.5432
unix 2 [ ACC ] SEQPACKET LISTENING 14550 - /run/udev/control