Hi I'm building a website with nginx, uwsgi and a postgresql database. When I want to access the database with
curl -i -X POST -H 'Content-Type: application/json' -d '{"username": "test", "password": "test", "email":"test"}' xxx.xxx.xxx
I get the following error: HTTP/1.1 502 Bad Gateway
The nginx/access.log file tells me: "POST /main/newuser HTTP/1.1" 502 173 "-" "curl/7.35.0"
and the nginx/error.log file says: upstream prematurely closed connection while reading response header from upstream
request: "POST /main/newuser HTTP/1.1", upstream: "uwsgi://unix:/var/www/mysite2/mysite2.sock:"
Everything else, beside accessing the database seems to work. When I run the my webserver on the localhost the connection with the database works.
Here my configuration files:
sites-enabled/project
upstream db {
server xxx.xxx.xxx:5432;
}
server {
listen 80;
server_name xxx.xxx.xxx;
location / {
proxy_pass http://db;
proxy_redirect off;
include uwsgi_params;
uwsgi_pass unix:/var/www/mysite2/mysite2.sock;
}
}
the uwsgi.ini file;
[uwsgi]
module = wsgi
master = true
processes = 5
socket = mysite2.sock
chmod-socket = 660
vacuum = true
die-on-term = true
python-path = /var/www/mysite2
Thanks in advance for your help!