ENETRESET
Linux / POSIXERRORNotableNetworkHIGH confidence
Network Dropped Connection on Reset
Production Risk
Indicates connection was forcefully terminated; implement reconnect logic.
What this means
ENETRESET (errno 102) is returned when the remote host sent a reset (RST) that terminated the connection, or when the network stack reset the connection due to a keep-alive failure.
Why it happens
- 1Remote host sent TCP RST during an established connection
- 2TCP keep-alive probes failed — remote host unreachable
- 3Intermediate firewall reset the connection
How to reproduce
read() on a TCP connection that was reset by the remote peer.
trigger — this will error
trigger — this will error
ssize_t n = read(sockfd, buf, sizeof(buf)); // Returns -1, errno = ENETRESET if network reset the connection
expected output
read: Network dropped connection on reset (ENETRESET)
Fix
Reconnect and retry
WHEN After ENETRESET
Reconnect and retry
if (errno == ENETRESET) {
close(sockfd);
sockfd = reconnect_to_server();
}Why this works
ENETRESET is terminal for the connection; close and reconnect.
Sources
Official documentation ↗
Linux Programmer Manual tcp(7)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev