• Register
0 votes
1.3k 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?

7.5k 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.

38.6k points

Related questions

0 votes
1 answer 5 views
5 views
Problem: Is there somebody who can assist : Failed to read pid from file /run/nginx.pid: invalid argument?
asked Jun 22 Mezbah 130k points
0 votes
1 answer 109 views
109 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 29.1k points
0 votes
1 answer 582 views
582 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 8 views
8 views
Problem: Where should I look for help with this issue : "primary script unknown" while reading response header from upstream?
asked Jun 18 Florina Gulnar 106k points
0 votes
1 answer 250 views
250 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 33 views
33 views
Problem: HELP! I need help understanding this error > (104)connection reset by peer: mod_fcgid: error reading data from fastcgi server
asked Apr 26 ummeshani 10.8k points
0 votes
1 answer 81 views
81 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 43.4k points
0 votes
1 answer 7 views
7 views
Problem: How to ? Search the server logs for possible server side errors .
asked Mar 20 PkGuy 25.9k points
0 votes
1 answer 684 views
684 views
Problem: no python application found, check your startup logs for errors.
asked Feb 21 charles mathews 5.5k points
0 votes
2 answers 2.2k views
2.2k 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