A connection reset by peer error means the connection was reset, not that you have identified the application or device responsible. On Linux, ECONNRESET is a socket error; a firewall can also generate a TCP reset. Start by locating the failed operation in time, then compare the same connection at both ends before changing anything.
The practical question is: what happened immediately before this connection became unusable? A reset on a new connection, one during a transfer and one when reusing an idle connection need different investigations. Keep the original error, timestamps and request context together rather than replacing them with a generic connectivity test.
This guide uses Linux TCP diagnostics and HTTP/1.1 as its application example. Run the commands in a POSIX-compatible shell on systems you administer, with iproute2, systemd and the named utilities available. Packet capture requires explicit authorisation and suitable privileges. Replace every angle-bracket placeholder before running a command.
What a peer-reset message establishes
A TCP reset terminates the affected TCP connection rather than completing an orderly exchange. The word “peer” describes the connection relationship visible to the socket interface; it is not an authenticated statement identifying the physical origin of every reset packet. Netfilter's REJECT target, for example, can return a TCP RST without the application generating it.
There are also two different outcomes to separate: the connection failed, and the requested work failed. A client that loses the response cannot conclude that the server never applied the request. That distinction becomes critical when the request creates or changes something.
Do not start by increasing every timeout, disabling filtering or restarting unrelated services. Write down the exact operation that failed: connecting, negotiating the application protocol, sending a request, reading a response or reusing an existing connection. The next diagnostic action should answer one remaining question about that operation.
Separate immediate, mid-transfer and idle resets
Use timing to choose where to investigate, not to declare a cause. The following are conditional diagnostic branches, not observations from a particular outage.
| Observed pattern | Next evidence to collect | Conclusion to avoid |
|---|---|---|
| Reset immediately on a new connection | Endpoint acceptance/protocol logs and the first packets of that connection | “The application crashed” without matching evidence |
| Reset during a request or response | Last successful application step, bytes transferred and corresponding endpoint errors | Treating partial delivery as proof of a completed operation |
| First request after an idle interval fails | Whether the client reused a pooled connection and whether the other endpoint had already closed it | Applying a universal keepalive value |
| Resets coincide with increased load | Connection counts, worker failures and relevant resource or policy events in the same interval | Buying more capacity before identifying the constraint |
For an immediate reset, inspect the connection segment that accepted the client and any protocol negotiation before the error. For an idle pooled-connection reset, compare the last successful use with closure and reuse events. HTTP/1.1 permits persistent connections, but a client or server can close them asynchronously; a request can race with an idle close.
For a reset under load, collect evidence before tuning kernel behaviour. Linux documents specific settings that can reset connections under particular resource conditions, but their existence does not establish that they caused your incident. Correlate the actual setting and relevant system message with the failing connection.
Correlate timestamps and endpoint logs
Start with one authorised failing operation. For a request that changes state, first establish its outcome from the application's own records; use a safe test request or staging reproduction where repeating the original could duplicate work. Record the start, failure time, client version, destination, protocol, connection reuse status and available request identifier.
Print a UTC timestamp on each participating Linux host:
date -u '+%Y-%m-%dT%H:%M:%SZ'
This displays the time without changing the clock. Account for clock differences when aligning events: the same displayed second on two unsynchronised machines is not necessarily the same instant.
For an application that writes to the systemd journal, query its actual unit over the recorded interval. Replace the start and end with journal-compatible date-time values and retain the UTC interpretation:
sudo journalctl -u '<UNIT>' \
--since '<START_UTC>' --until '<END_UTC>' \
--utc --no-pager
Read the client and server records together. Use the application's configured log destination when it does not log to journald. An empty unit query establishes only that this query returned no matching records, not that no request arrived.
Inspect established sockets while reproducing a safe instance of the issue:
ss -nto state established
The output shows numeric TCP endpoints and available timer information. Match both addresses and ports to the failing connection. A snapshot taken after the reset may no longer contain that socket; a host-namespace view also does not inventory every container network namespace.
As a separate fresh-connection comparison for an authorised, read-only HTTP/1.1 endpoint, use:
curl -q --http1.1 --verbose \
--connect-timeout 5 --max-time 15 \
--output /dev/null 'https://<HOSTNAME>/<READ_ONLY_PATH>'
The five- and fifteen-second values are deliberate limits for this diagnostic probe, not recommended production timeouts. -q, placed first, disables curl's default configuration file. The command adds no retries or redirect following. Keep certificate validation enabled. A fresh curl request does not reproduce an existing application's idle connection pool.
Preserve the error and response information, but redact authorisation headers, cookies, tokens and personal data before sharing diagnostics. A successful status response is useful evidence only for the endpoint and operation actually exercised.
Inspect the path and possible intermediaries
Draw the path from the failing client to the component it actually connects to. Include any configured reverse proxy, load balancer or connection-terminating gateway. An HTTP intermediary can participate in multiple connections, so correlate its client-facing and upstream records separately rather than treating the entire path as one socket.
Where packet inspection is authorised, observe one relevant interface and connection. This command stops after twenty matching packets or a fifteen-second duration; the additional two-second grace bounds termination if the capture process does not stop normally:
sudo timeout -k 2s 15s tcpdump -ni '<INTERFACE>' -c 20 \
'host <CLIENT_IP> and tcp port <PORT>'
These are defined capture limits. The interface, visible client address and port must match the observation point, including address translation where present. The command does not request a capture file or full payload display. Its output still contains network metadata that should be handled as sensitive.
Compare permitted observations near both endpoints. Look for the relevant connection's establishment, data, orderly closure and reset flags. Do not filter only for RST packets initially: the preceding exchange is part of the explanation. A twenty-packet limit can finish before the failure, so record whether the capture actually included the incident.
An RST visible toward the client but absent from a server-side capture narrows an investigation only when both captures covered the correct connection and interval. Wrong interfaces, filters, namespaces or dropped capture packets can invalidate that comparison. Likewise, an address in the packet is not enough to distinguish an endpoint response from an intermediary-generated rejection.
Collect the relevant firewall or intermediary event for the same flow where those records exist. Keep the rule identity, connection segment and timestamp with the packet evidence. Do not erase policy to make the symptom disappear; that removes both protection and a useful basis for comparison.
Choose keepalive, timeout or application fixes from evidence
Separate three settings before touching any of them: the application's request deadline, its reusable-connection lifetime and the operating system's TCP keepalive behaviour. They govern different parts of the exchange. On Linux, TCP keepalive probes depend on SO_KEEPALIVE being enabled, and application or connection-tracking timeouts can be shorter.
For the idle-pool branch, examine the client's recorded reuse event alongside the remote close. When those records demonstrate reuse after closure, change the responsible client's documented pool handling: retire expired connections, respect closure and create a replacement connection when needed. Reproduce the same safe idle/reuse pattern afterwards. Merely opening a fresh connection bypasses the condition being investigated.
For the immediate-reset branch, a matching policy event or application error should lead to that specific rule or application configuration, not pool tuning. Correct only the demonstrated mismatch. Apply the change through the responsible component's documented reload, restart or deployment procedure, then inspect its effective configuration before retesting.
Increasing a local waiting period cannot reverse an already received reset. Nor does keepalive establish that an HTTP request finished. Linux's TCP_USER_TIMEOUT separately controls certain periods of unacknowledged or untransmitted data; it is not a generic HTTP request deadline or an instruction to keep every connection open indefinitely.
Before any change, retain the previous configuration and management access. Define the expected improvement and rollback condition. A new error, failed reload or loss of the required application behaviour is a reason to restore the previous configuration and reassess, not to stack unrelated changes on top.
Retest and bound retry behaviour
Retest the original safe operation through the same path and under the relevant connection lifecycle: fresh connection, active transfer or idle reuse. Compare the application result as well as the socket outcome. Record a complete expected response or the application's verified resulting state; disappearance of one log line alone is not a completed diagnosis.
For HTTP, idempotency means repeating the request has the same intended effect as making it once. It does not mean that a failed connection proves nothing happened. Automatically replay a non-idempotent operation only when its actual semantics or an established outcome-detection mechanism make that safe. A POST that creates work must not be replayed merely because no response reached the client.
Keep retry attempts and elapsed time bounded, and retain the initial error. Curl explicitly warns that retrying every error can send or receive duplicate data; its per-transfer time limit and overall retry-time controls also serve different purposes. A retry that eventually succeeds does not identify what reset the original connection.
The useful final record is specific: which operation failed, which connection segment was implicated, what evidence supported the change and whether the same operation then completed correctly. On our Linux VPS, full root access provides the control needed to inspect and administer your server-side configuration. Use that control to fix the demonstrated cause, not to make the whole network less restrictive.