Welcome! Log In Create A New Profile

Advanced

502 Gateway Error - when accessing postgresql database

November 15, 2016 09:49PM
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!
Subject Author Posted

502 Gateway Error - when accessing postgresql database

Nanoq November 15, 2016 09:49PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 233
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready