Connection reset by peer -- RST received from server, backend overload or bug
curl: (56) Connection reset by peer
Focused incident mode — strips away everything but this runbook.
Symptoms
- curl: (56) Connection reset by peer
- Application logs show ECONNRESET errors intermittently under load
- tcpdump shows a RST packet from the server after the connection is established
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
RST packets in a capture
tcpdump -i any host <SERVER> and port <PORT> -c 20 'tcp[tcpflags] & (tcp-rst) != 0' -nnServer-side socket stats
ss -s && ss -tnp | grep <PORT>
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- ss shows a high SYN_RECV or ESTABLISHED count
- RSTs spike during traffic bursts
- somaxconn is at the default 128
Confirm before fixing
cat /proc/sys/net/core/somaxconn && ss -tnp | grep LISTEN | awk '{print $4}' | sort | uniq -c | sort -rn | headCheck the backlog limit and per-port listen queue depths
Fix
sysctl -w net.core.somaxconn=4096Raise the listen backlog limit
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
tcpdump -i any host <SERVER> and port <PORT> -c 10 -nn 'tcp[tcpflags] & (tcp-rst) != 0'Capture RST packets to confirm server-originated resets
ss -s && ss -tnp | grep <PORT>Check socket state and listen backlog
cat /proc/sys/net/core/somaxconnRead the backlog limit
sysctl -w net.core.somaxconn=4096Raise the backlog limit if it is the bottleneck
Prevention
- Increase somaxconn and application listen backlog for high-traffic services.
- Monitor TCP RST counters (netstat -s | grep reset) and alert on spikes.
- Use connection pooling on the client side to reduce churn.
- Implement graceful shutdown to drain connections instead of resetting them.
Related runbooks
Same stack, same failure family — worth a skim.
curl: Connection refused immediately (no timeout delay)
curl returns HTTP 502 Bad Gateway
dmesg shows 'nf_conntrack: table full, dropping packet'
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.