What does "connection reset by peer" mean?
Asked Answered
H

2

934

What is the meaning of the "connection reset by peer" error on a TCP connection? Is it a fatal error or just a notification or related to the network failure?

Hordein answered 16/9, 2009 at 17:38 Comment(0)
W
1097

It's fatal. The remote server has sent you a RST packet, which indicates an immediate dropping of the connection, rather than the usual handshake. This bypasses the normal half-closed state transition. I like this description:

"Connection reset by peer" is the TCP/IP equivalent of slamming the phone back on the hook. It's more polite than merely not replying, leaving one hanging. But it's not the FIN-ACK expected of the truly polite TCP/IP converseur.

Wamsley answered 16/9, 2009 at 17:48 Comment(11)
Why is it labelled "connection reset by peer”? It sounds like it should be "connection reset by the host", or "connection reset by the server"Intergrade
@Intergrade Because that's where the reset came from. The peer sent an RST packet.Wertz
... Robert, your concern makes no sense to me. Peer is just strictly more general than that. In a typical client-server model, the server can just as easily receive this notification from the "client". The machine that initially requests the connection has just as much power to send this notification. On a TCP level, it looks identical once the connection is ongoing. The two machines, when communicating, are just peers.Woodchopper
Does this caused by high memory utilization on the client server (not the remote server) due to server hangs?Selwyn
@Selwyn It is most usually caused by either premature process exits,mfor any reason, or premature socket closes when there is still unread data or data in flight,Wertz
This packed could have been sent by another device in the middle like a router?Dignity
How can we bypass such scenario? Is there any JVM or server property for the same which can be modified?Hoye
It cannot be called 'connection reset by server' because it can be sent by the client or the server. It cannot be 'bypassed'. If a client receives this error this means the TCP connection is no longer open in the server, for example since the server crashed and was restarted.Garrott
@Roel I find that very hard to believe. Impossible actually. The error message comes from the localhost, and the localhost doesn't know what hardward is at the other end. The localhost didn't receive that text, only an RST flag.Wertz
I think the most misleading thing about this mesage, has nothing to do about the server and client relationship, it's that it's apparently also sent by routers when they reboot without servers or clients doing it so the servers or clients get the delusion from the message that the reset did not come from routing infrastructure.Bureaucratic
It means you know what IRC is!Rauscher
W
276

This means that a TCP RST was received and the connection is now closed. This occurs when a packet is sent from your end of the connection but the other end does not recognize the connection; it will send back a packet with the RST bit set in order to forcibly close the connection.

This can happen if the other side crashes and then comes back up or if it calls close() on the socket while there is data from you in transit, and is an indication to you that some of the data that you previously sent may not have been received.

It is up to you whether that is an error; if the information you were sending was only for the benefit of the remote client then it may not matter that any final data may have been lost. However you should close the socket and free up any other resources associated with the connection.

Wrong answered 16/9, 2009 at 18:7 Comment(5)
If you set the socket option SO_LINGER to zero when opening a new socket, then close it normally, the RST bit will be set. So ALL connection will end with a reset. Don't try this it at home, its just annoying. stackoverflow.com/questions/3757289Tonneau
How to fix this issue then, do we need to restart both remote and our host?Samaritan
@Samaritan You need to reconnect the client, but first you need to examine your software to make sure it isn't due to an application protocol error, i.e. closing a connection that the other end is still writing to.Wertz
Thanks for your comment. It used to work for two months. I am also trying it from a command line, but still getting this error. I tries "sftp user@machine". Error is inconsistent.Samaritan
It's also very common to be sent by routing hardware which reboots, in which case neither a server or a client sent the resetting message, so it can be a misleading message.Bureaucratic

© 2022 - 2024 — McMap. All rights reserved.