• Register
0 votes
994 views

Problem :

My Environment is Nginx + uwsgi and I am very new to it.

I am getting a 502 bad gateway error from Nginx on certain GET requests. It seems to be related to a length of  URL..

Please find below the nginx/error.log

[error] 22113#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.1.100, server: server.domain.com, request: "GET <long_url_here>"

Can somebody solve this issue?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Whenever we receive a message like follows:

 (104: Connection reset by peer) while reading response header from upstream,

Generally, we can blame the upstream side of this kind of error.

Here the connection was reset by the upstream peer and not by nginx itself. So Nginx as a client cannot do anything to make it right.

I am thinking if modifying buffer size will do the magic. Basically the command will change the buffer size where response headers are cached. This will take effect only when the response header is too big and in that case we receive a following message saying:

 upstream sent too big header while reading response header from upstream, and please note that it is totally different thing from connection reset by peer.

As this kind of error is triggered randomly, I would suggest you check whether your nginx uses keepalive when talking to upstreams. If this was the case then the connection may be reset by upstream server when the idle timed out whereas nginx had no idea that the connection had been dropped, so forwarding the request using the same connection.

You can set a keepalive_timeout value to the upstream connection pool in nginx to avoid the problem.

9 7 4
38,600 points

Related questions

0 votes
1 answer 13 views
13 views
Problem: I get an error in the Nginx log: upstream timed out (110: Connection timed out) while reading response header from upstream
asked Mar 15 ummesalma 22.9k points
0 votes
1 answer 410 views
410 views
Problem : Currently I am using the nginx and node server to serve the update requests. I often face the gateway timeout whenever I request an update on large data. I saw below error from the nginx error logs as below : 2019/04/07 00:46:04 [error] 28599#0: *1 upstream ... time around 3-4 minutes. Please note I do not get the error for smaller updates. Please let me know how can I resolve the issue.
asked Dec 18, 2019 alecxe 7.5k points
0 votes
1 answer 30 views
30 views
Problem: fastcgi sent in stderr: "primary script unknown" while reading response header from upstream,
asked Feb 19 Lucky Guy 1.5k points
0 votes
1 answer 5 views
5 views
Problem: Anyone knows about this error so please tell me .. no python application found check your startup logs for errors
asked Apr 2 Ifra 24.4k points
0 votes
1 answer 18 views
18 views
Problem: When using Python 2.7 with urllib2 to retrieve data from an API, I get the error [Errno 104] Connection reset by peer. Whats causing the error, and how should the error be handled so that the script does not crash?
asked Feb 19 Mashhoodch 13k points
0 votes
1 answer 25 views
25 views
Problem: I'm having this strange error, CURL ERROR: Recv failure: Connection reset by peer.
asked Feb 25 Umar Ahmad 4.1k points
0 votes
1 answer 53 views
53 views
Problem: curl 56 recv failure connection reset by peer I'm having this strange error, CURL ERROR: Recv failure: Connection reset by peer .I've added in the following toe remove the default header and still no luck. Kindly Help help me to fix it !
asked Feb 25 Umar Ahmad 4.1k points
0 votes
1 answer 2 views
2 views
Problem: How to ? Search the server logs for possible server side errors .
asked Mar 20 PkGuy 13.1k points
0 votes
1 answer 63 views
63 views
Problem: no python application found, check your startup logs for errors.
asked Feb 21 charles mathews 5.5k points
0 votes
2 answers 1.3K views
1.3K views
Problem : I have below error message on the django 1.4: &ldquo;Dictionary update sequence element #0 has length 1; 2 is required&rdquo; It happened to me when I tried using a template tag like: `{% for v in values %} It happens too when I try to access ... rendering too. I just restarted the uwsgi and everything works well, but above error comes back later. Has someone an idea to fix this error?
asked Jan 22, 2020 jwilliam 3.9k points