502 Bad Gateway: upstream prematurely closed connection while reading response header from upstream, client:

I am not sure whether this is the right place to post this question. I have just added more data into my app's database.

I am able to see the home page and the about page but when i try to access other pages that should output lots of data, i get a 502 Bad Gateway.

I checked the error log and it reads something like this:

2020/08/04 15:17:26 [error] 755#755: *18 upstream prematurely closed connection while reading response header from upstream, client: 105.166.97.208, server: sarscov2web.org, request: "GET $ 2020/08/04 15:17:26 [error] 755#755: *18 connect() failed (111: Connection refused) while connecting to upstream, client: 105.166.97.208, server: sarscov2web.org, request: "GET /annotatedT$

netstat -plant gives the following output
.tables
Proto Recv-Q Send-Q Local Address | Foreign Address | State PID/Program name

tcp | 0 | 0 0.0.0.0:443 | 0.0.0.0:* | LISTEN -
tcp | 0 | 0 127.0.0.1:8000 | 0.0.0.0:* | LISTEN 809/python3
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 612 172.104.50.30:22 105.166.97.208:58414 ESTABLISHED -
tcp6 0 0 :::22 :::* LISTEN -

Is it possible that the nginx is timing-out? If yes, what should i do to fix this?

1 Reply

I have solved the problem by optimizing my SQL queries which were a tad too slow.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct