• Register
0 votes
574 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

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 248 views
248 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 387 views
387 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 jwilliam 3.9k points
0 votes
1 answer 41 views
41 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 LizzyM 6.1k points
0 votes
1 answer 154 views
154 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 308 views
308 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