• Register
0 votes

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:, 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 303 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
2 answers 796 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
0 votes
1 answer 3 views
What can cause this exception?
asked Dec 19, 2020 TeamScript 9.2k points
0 votes
1 answer 72 views
Problem: I am seeing "{writer,send_failed,{error,closed}}" error on server side and "java.net.SocketException: Connection reset by peer: socket write error" error on java client side intermittently. What could possibly go wrong here? Both server and ... rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:630) at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:621) Please help me.
asked Mar 23, 2020 LizzyM 6.1k points
0 votes
1 answer 221 views
Problem : I am trying to implement an HTTP Server using Sockets but getting bellow error java net socketexception connection reset by peer socket write error
asked Oct 31, 2019 peterlaw 6.9k points
1 vote
2 answers 374 views
What is the meaning of the "connection reset by peer" error on a TCP connection? Why do we get the error "Connection reset by peer" during a web service call? Explaining Connection Reset by Peer Log Messages? Is it a fatal error or just a notification or related ... it mean when it says the connection was reset? How do I fix my connection reset? What does Connection reset by peer mean on Instagram
asked Jul 23, 2019 sadmin 2.1k points
0 votes
1 answer 44 views
Problem : I got below problem which I am trying to fix from the few days now and I am unable to know what should I do, I am looking for the answers but all of those which I found are of no use for me. I am very new here so I really hope that somebody can help me in resolving my error $ ... ------------ f...e) Jan 05 13:23:33 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e)
asked Jan 6, 2020 alecxe 7.5k points
1 vote
1 answer 69 views
Problem : I am facing the problem which I am trying to fix from the couple of days now and still I don't know what should I do, I am searching for answers but all of those I came across are of no use to me. I am very new here and I am really hopeful ... systemd/system/nginx.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sun 2019-12-29 13:23:35 GMT; 2min 20s ago
asked Dec 30, 2019 alecxe 7.5k points
0 votes
1 answer 8 views
Help me by solving this question.
asked Jan 4 TeamScript 9.2k points
1 vote
2 answers 115 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 27, 2020 LizzyM 6.1k points