Skip to content
Proxy fundamentals

Connection reset by peer: what it means and how to fix it

Connection reset by peer means the far end aborted the TCP connection with a RST. Real output from curl, Python, Node and Chrome, each cause and its fix.

On this page 7 sections
  1. Reset, close or refused: confirm which one you have
  2. What actually sends a reset
  3. Find out which hop sent it
  4. The causes, and the fix for each
  5. 1. A reused keep-alive connection the server had just closed
  6. 2. The server read your request and aborted
  7. 3. A reset during the TLS handshake
  8. 4. Proxy causes: CONNECT, authentication, interception and upstream refusal
  9. 5. The transfer was cut part-way through the body
  10. 6. A large upload the server refused early
  11. 7. Restarts, reboots and forgotten NAT state
  12. 8. A reset injected by the network
  13. 9. You are the peer: resets in your own server logs
  14. Cloudflare: 520, 521 and the 1xxx codes
  15. Cause-to-fix table
  16. How this was tested

These are the same error in seven clients, each captured on one machine against local servers built to fail on purpose:

curl: (56) Recv failure: Connection reset by peer
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
httpx.ReadError: [Errno 54] Connection reset by peer
Error: read ECONNRESET
Get "http://127.0.0.1:47181/": read tcp 127.0.0.1:56400->127.0.0.1:47181: read: connection reset by peer
java.net.SocketException: Connection reset
net::ERR_CONNECTION_RESET

The machine at the other end of your TCP connection sent a reset segment (RST). It did not close the connection the normal way, the way a server does once it has finished answering. It aborted it, and your operating system reported that as ECONNRESET. Whatever was in flight is lost. “Peer” just means whoever holds the far end of that socket, and when you connect through a proxy, that is the proxy rather than the website.

Each cause below comes with a check and a fix. Versions and the test setup are at the end of the page.

Reset, close or refused: confirm which one you have

Three different failures get described as “the connection died”, and they have different causes. We pointed each client at three local ports: one that reads the request and answers with a RST, one that closes cleanly with a FIN and sends nothing, and one with nothing listening.

Client Server sent RST Server closed (FIN), no response Nothing listening
curl 8.23.0 (56) Recv failure: Connection reset by peer (52) Empty reply from server (7) Failed to connect to 127.0.0.1:47184 after 0 ms: Could not connect to server
Python requests 2.32.3 ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer')) ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) Failed to establish a new connection: [Errno 61] Connection refused
httpx 0.27.2 httpx.ReadError: [Errno 54] Connection reset by peer httpx.RemoteProtocolError: Server disconnected without sending a response. httpx.ConnectError: [Errno 61] Connection refused
Node 24.2.0 fetch TypeError: fetch failed, cause read ECONNRESET TypeError: fetch failed, cause SocketError: other side closed TypeError: fetch failed, cause connect ECONNREFUSED 127.0.0.1:47184
Node 24.2.0 node:http Error: read ECONNRESET Error: socket hang up (code ECONNRESET) connect ECONNREFUSED 127.0.0.1:47184
Go 1.24.4 net/http read: connection reset by peer EOF connect: connection refused
Java 17 HttpURLConnection java.net.SocketException: Connection reset java.net.SocketException: Unexpected end of file from server —
Chrome 155 net::ERR_CONNECTION_RESET net::ERR_EMPTY_RESPONSE net::ERR_CONNECTION_REFUSED

Two rows can mislead you. Node’s node:http labels a clean FIN as socket hang up and still gives it the code ECONNRESET, even though no reset was ever sent, so check err.message as well as err.code. Java’s newer java.net.http.HttpClient printed HTTP/1.1 header parser received no bytes for both the RST and the FIN, which means it cannot tell you which one happened. Chrome is the most precise: Chromium’s error list defines ERR_CONNECTION_CLOSED (-100) as “corresponding to a TCP FIN” and ERR_CONNECTION_RESET (-101) as “corresponding to a TCP RST”.

The number inside the Python message is the operating system’s error code, not anything HTTP. The same reset is errno 54 on macOS and 104 on Linux; we printed errno.ECONNRESET on both and got exactly those. Windows calls it WSAECONNRESET, error 10054, which Microsoft’s Winsock reference describes as “An existing connection was forcibly closed by the remote host”. So “errno 104” is not an HTTP 104. There is no such status code.

Refused and empty reply are different problems. “Connection refused” means nothing accepted the connection at all: wrong host, wrong port or a stopped service. “Empty reply from server” means the server closed cleanly without answering. Neither is a reset, and most of the fixes below do not apply to them.

What actually sends a reset

TCP has two ways to end a connection. A FIN says “I have nothing more to send.” A RST says “this connection no longer exists.” The TCP specification, RFC 9293, has a host answer with a reset whenever a segment arrives for a connection it has no record of. In practice resets come from four places:

  • The far end closed while your data sat unread. RFC 1122 section 4.2.2.13 says that if an application closes while received data is still pending, TCP “SHOULD send a RST to show that data was lost”. Linux does it in tcp_close(), with a comment pointing to RFC 2525 section 2.17.
  • The application chose an abortive close. Setting SO_LINGER to zero and then closing sends a RST instead of a FIN. nginx documents its reset_timedout_connection option in exactly these terms. Our test servers used the same trick.
  • The connection no longer exists over there. The host rebooted, the process lost its state, or a NAT or firewall in the path dropped the mapping. Your next packet reaches a host with no record of it. Node’s error reference describes ECONNRESET as usually “a loss of the connection on the remote socket due to a timeout or reboot”.
  • Something in the middle forged it. Weaver, Sommer and Paxson’s NDSS 2009 study of injected resets found them coming from ISP traffic-control devices, anti-spam and anti-virus systems and national censorship, as well as ordinary terminations by NATs and load balancers.

Find out which hop sent it

Run the failing request once with curl in verbose mode. Where the reset falls in the transcript tells you more than the final error line.

curl -v -o /dev/null https://target.example/
curl -v -o /dev/null -x http://user:pass@gw.example.net:8000 https://target.example/

Here is a server that reads the request and then aborts, seen by curl 8.23.0 (progress meter removed):

*   Trying 127.0.0.1:47181...
* Established connection to 127.0.0.1 (127.0.0.1 port 47181) from 127.0.0.1 port 59769
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 127.0.0.1:47181
> User-Agent: curl/8.23.0
> Accept: */*
>
* Request completely sent off
* Recv failure: Connection reset by peer
* closing connection #0
curl: (56) Recv failure: Connection reset by peer

Read it by position:

  • Reset before any TLS line: the TCP connection was accepted, then killed. The server, a load balancer or a firewall in front of it.
  • Reset right after TLS handshake, Client hello (1): something refused your ClientHello. See cause 3.
  • Reset after Request completely sent off: the server read the request and aborted instead of answering. Cause 2, or cause 1 if the connection was reused.
  • Reset after part of the body arrived: the transfer was cut. Cause 5.
  • Through a proxy, reset before CONNECT tunnel established: the proxy, or the path to it, rejected you. After the 200, the proxy tore the tunnel down. Cause 4.

With root on either end, a packet capture names the sender outright. The filter is documented in the pcap-filter manual:

sudo tcpdump -ni any 'tcp[tcpflags] & tcp-rst != 0'    # Linux; on macOS use -i en0

Compare the RST’s source address with the address you think you are talking to. We did not have root on the test machine, so everything else on this page comes from the clients’ own output.

The causes, and the fix for each

They are listed in the order worth ruling out: the first is the one you can fix in your own code, and the later ones need someone else’s logs.

1. A reused keep-alive connection the server had just closed

HTTP clients keep idle connections in a pool. Servers and load balancers close idle connections on their own timers: nginx’s keepalive_timeout defaults to 75 seconds, Node’s server.keepAliveTimeout to 5,000 ms, and an AWS Application Load Balancer’s idle timeout to 60 seconds. If your client sends a request at the moment the server gives up on the connection, the request lands on a socket the server has already released, and the server’s kernel answers with a reset. AWS describes the same race from the load balancer’s side and recommends giving the application an idle timeout larger than the load balancer’s.

The failure is intermittent, which is why it eats so much time. We reproduced it with a server that closes idle connections after 1.0 s and does not announce that timeout in a Keep-Alive header, as many servers do not. Each trial sent one request, waited, then reused the connection for a second.

Share of second requests that failed when reusing a keep-alive connection around a 1.0 s server idle timeout, loopback, 21 October 2026 Drawn from the table below.
Share of second requests that failed when reusing a keep-alive connection around a 1.0 s server idle timeout, loopback, 21 October 2026. Bar chart of Failed (%) by Client and timing.5 rows, drawn from the table that follows this chart.Node 24.2.0, event loop blockedacross the closeNode 24.2.0, event loop blocked across the close: 100100Node 24.2.0, reuse at 990-1010 msNode 24.2.0, reuse at 990-1010 ms: 7.57.5requests 2.32.3, reuse at 990-1010msrequests 2.32.3, reuse at 990-1010 ms: 2.52.5Node 24.2.0, reuse at 1.2 s, eventloop idleNode 24.2.0, reuse at 1.2 s, event loop idle: 00requests 2.32.3, reuse at 1.2 srequests 2.32.3, reuse at 1.2 s: 00050100%Share of second requests that failed when reusing a keep-alive connection around a 1.0 s server idle timeout, loopback, 21 October 2026. Bar chart of Failed (%) by Client and timing.5 rows, drawn from the table that follows this chart.Node 24.2.0, event loopblocked across the closeNode 24.2.0, event loop blocked across the close: 100100Node 24.2.0, reuse at990-1010 msNode 24.2.0, reuse at 990-1010 ms: 7.57.5requests 2.32.3, reuse at990-1010 msrequests 2.32.3, reuse at 990-1010 ms: 2.52.5Node 24.2.0, reuse at 1.2s, event loop idleNode 24.2.0, reuse at 1.2 s, event loop idle: 00requests 2.32.3, reuse at1.2 srequests 2.32.3, reuse at 1.2 s: 00050100%
Client and timing Failed (%) Failed / trials Error seen
Node 24.2.0, event loop blocked across the close 100 20 / 20 19 read ECONNRESET, 1 socket hang up
Node 24.2.0, reuse at 990-1010 ms 7.5 3 / 40 2 read ECONNRESET, 1 socket hang up
requests 2.32.3, reuse at 990-1010 ms 2.5 1 / 40 ConnectionResetError(54, 'Connection reset by peer')
Node 24.2.0, reuse at 1.2 s, event loop idle 0 0 / 20 none
requests 2.32.3, reuse at 1.2 s 0 0 / 20 none; all 20 went out on a new connection

Clients cope well with a close that has already arrived. Both libraries noticed the FIN and opened a fresh connection when the gap was clearly past the timeout. The failures sit on the boundary, and a busy event loop widens it. When our Node script was running synchronous code at the moment the server’s FIN arrived, Node had no chance to process the close, handed the dead socket to the next request, and every one of 20 trials failed. That is the production version of this bug: it appears under CPU load and vanishes when you try to reproduce it on a quiet laptop. The counts come from loopback with no network delay, so treat them as a demonstration of the mechanism, not as a rate to expect.

The fix has two parts. First, where your client lets you set an idle timeout for pooled connections, set it below the server’s, so the client always gives up first. Second, retry once on a fresh connection, and only for idempotent requests. RFC 9110 says a client “SHOULD NOT automatically retry a request with a non-idempotent method” unless it knows the request is safe to repeat. A POST that was reset may already have been processed.

In Python, urllib3’s Retry does this when mounted on a requests session. Tested with requests 2.32.3 and urllib3 2.3.0:

import sys
import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry

# One retry on a fresh connection. urllib3 only retries methods in
# Retry.DEFAULT_ALLOWED_METHODS (GET, HEAD, PUT, DELETE, OPTIONS, TRACE).
retry = Retry(total=1, connect=1, read=1, status=0, backoff_factor=0.2)
session = requests.Session()
session.mount("http://", HTTPAdapter(max_retries=retry))
session.mount("https://", HTTPAdapter(max_retries=retry))

url = sys.argv[1]
print(session.get(url, timeout=10).text.strip())   # opens a connection
print(session.get(url, timeout=10).text.strip())   # reuses it; retried if reset

To test it deterministically we used a server that serves the first request on each connection and resets the second, which pins the race’s outcome. Without the adapter, 20 of 20 reused requests failed with ConnectionResetError(54). With it, 20 of 20 succeeded on a new connection. The same Retry left POST alone: 5 of 5 POSTs still failed, which is the behaviour you want.

Node’s documentation for request.reusedSocket describes this exact race and suggests checking that flag before retrying. A promise version, tested on Node 24.2.0:

import http from "node:http";

const agent = new http.Agent({ keepAlive: true });

// Retry once when a request on a reused keep-alive socket is reset.
// Only for idempotent requests: a GET here.
function get(url, retried = false) {
  return new Promise((resolve, reject) => {
    const req = http.get(url, { agent }, (res) => {
      let body = "";
      res.on("data", (d) => (body += d));
      res.on("end", () => resolve(body.trim()));
    });
    req.on("error", (err) => {
      if (!retried && req.reusedSocket && err.code === "ECONNRESET") {
        resolve(get(url, true));
      } else {
        reject(err);
      }
    });
  });
}

const url = process.argv[2];
console.log(await get(url));   // opens a socket
console.log(await get(url));   // reuses it; retried if reset
agent.destroy();

Against the always-reset server it recovered 20 of 20 reused requests, and in the blocked-event-loop race that had failed 20 of 20, it recovered all 20. The reusedSocket check matters: it limits the retry to the one case where a retry is likely to help. Note that it also catches socket hang up, because Node gives that the same code. For the wider retry pattern, including jitter, see exponential backoff, and the Python and Node specifics in using proxies in Python and using proxies in Node.js.

2. The server read your request and aborted

Every request resets, right after Request completely sent off. The server, or something in front of it, decided not to answer. nginx has a dedicated non-standard code for this: return 444 closes the connection without a response, and with reset_timedout_connection on nginx sends a RST instead of a FIN. Application crashes, worker restarts and security rules at a load balancer produce the same picture from the outside.

To narrow it down, request something trivial on the same host with the same client, such as /robots.txt, then repeat the failing request from a different network. If everything resets, the service or its infrastructure is the problem. If only some requests do, a rule is matching something about those requests. When you run the server, the error log usually says which part gave up. nginx, for example, writes recv() failed (104: Connection reset by peer) while reading response header from upstream when the application behind it resets nginx’s connection. That line is assembled in ngx_recv.c, ngx_log.c and ngx_http_upstream.c, and the 104 is the errno on nginx’s Linux host. When you do not run the server, a reset is the operator’s decision. Slow down, check you are sending a well-formed request, and ask them. Retrying in a tight loop will not change their answer.

3. A reset during the TLS handshake

A server that resets right after your ClientHello produced this, direct, with curl 8.23.0 built on OpenSSL 4.0.3 (trust-store lines trimmed):

* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* Recv failure: Connection reset by peer
* TLS connect error: error:00000000:lib(0)::reason(0)
* OpenSSL SSL_connect: Connection reset by peer in connection to 127.0.0.1:47443
* closing connection #0
curl: (35) Recv failure: Connection reset by peer

requests reported ConnectionResetError(54), httpx httpx.ConnectError: [Errno 54] Connection reset by peer, and Chrome net::ERR_CONNECTION_RESET. Compare a server that simply disagrees with your TLS settings. We ran an openssl s_server that accepts TLS 1.3 only and connected with --tls-max 1.2:

curl: (35) TLS connect error: error:0A00042E:SSL routines::tlsv1 alert protocol version

A TLS server that does not like your offer says so with an alert. A reset in its place usually means your bytes reached something that will not speak TLS for that name: a firewall filtering on the server name, a port that serves a different protocol, or a TLS terminator with no configuration for that hostname. To check, run the handshake by hand, then repeat it from a second network:

openssl s_client -connect target.example:443 -servername target.example -brief </dev/null

If it completes elsewhere and resets on your network, the reset is on your path and the network’s administrator is the person to ask. If it resets everywhere, check the hostname and port first, then the server’s TLS configuration. If the handshake completes and you then get a 403 or a challenge page, that is a different problem: see anti-bot systems and TLS fingerprinting.

4. Proxy causes: CONNECT, authentication, interception and upstream refusal

With a forward proxy, your TCP connection ends at the proxy. A reset sent by the website does not travel through it. The proxy decides what to tell you. We ran Squid 6.13 locally and pointed it at the same failing servers:

Situation curl 8.23.0 through Squid Chrome 155 through Squid Squid’s access log
Target resets the ClientHello inside a CONNECT tunnel (35) TLS connect error: error:0A000126:SSL routines::unexpected eof while reading, after CONNECT tunnel established, response 200 net::ERR_CONNECTION_CLOSED TCP_TUNNEL/200 CONNECT 127.0.0.1:47443
Target resets a plain-HTTP request HTTP/1.1 502 Bad Gateway with X-Squid-Error: ERR_READ_ERROR 54 Squid’s error page loaded TCP_MISS_ABORTED/502 ... ERR_READ_ERROR/WITH_SERVER
Nothing listening at the target (7) CONNECT tunnel failed, response 503 net::ERR_TUNNEL_CONNECTION_FAILED TCP_TUNNEL/503 ... ERR_CONNECT_FAIL/errno=61
Wrong proxy password (7) CONNECT tunnel failed, response 407 — TCP_DENIED/407 ... ERR_CACHE_ACCESS_DENIED
TLS spoken to a plain-HTTP proxy port (-x https://) (35) TLS connect error: error:0A00010B:SSL routines::wrong version number — NONE_NONE/400 error:invalid-request
SOCKS5 spoken to an HTTP proxy port Hung until our 10 s cap: (28) Connection timed out after 10000 milliseconds — ERR_CLIENT_GONE once curl gave up

Not one row reads “connection reset by peer”. The target’s reset stopped at the proxy. In the tunnel case Squid closed our side of the connection normally, so curl saw a TLS stream that ended early and Chrome saw a FIN. The practical rule: if you see a reset while using a proxy, it most likely came from the proxy itself or from something between you and it, not from the website. A different proxy can choose to abort your side with a RST when its upstream fails, and then the reset you see is still the proxy’s. To separate the two, send the same request through the same proxy to an endpoint you trust:

# CONNECT status and final status in one line
curl -sS -o /dev/null -w '%{http_connect} %{http_code}\n' \
  -x http://user:pass@gw.example.net:8000 https://example.com/

On our healthy control this printed 200 200. A failure here points at the proxy, its credentials or the route to it. Success here but failure on your target points beyond the proxy. The full option set is in how to use a proxy with curl, and the CONNECT exchange itself is explained under HTTP CONNECT.

Authentication failures came back as a status, not a reset. Squid answered 407, as RFC 9110 specifies for proxy authentication. SOCKS5 has no status pages, and RFC 1929 says a server that rejects the username and password “MUST close the connection”. A minimal server doing exactly that drew curl: (97) User was rejected by the SOCKS5 server (1 1). from curl and SOCKS5 authentication failed from requests 2.32.3 with PySocks 1.7.1. Both clients named the real problem. If a proxy resets you right after you authenticate, check the credentials, but expect that behaviour to be the provider’s design rather than the protocol’s. 403, 407 and 429 are covered in detail in 403 vs 407 vs 429.

Upstream refusal also comes back as a status from a well-behaved proxy: 503 when the target refused the connection, 502 when the target broke mid-request. curl exits with code 7 and prints the CONNECT status. Read that number before anything else, because it is the proxy’s own diagnosis.

TLS interception changes what you see. Inspection proxies decrypt HTTPS by minting their own certificate for every site. We ran Squid’s ssl-bump with a lab certificate authority. The quickest test for interception is to ask who signed the certificate you actually received:

$ echo | openssl s_client -proxy 127.0.0.1:47130 -connect 127.0.0.1:47444 2>/dev/null | openssl x509 -noout -issuer
issuer=CN=Lab Intercepting Proxy CA
$ echo | openssl s_client -connect 127.0.0.1:47444 2>/dev/null | openssl x509 -noout -issuer
issuer=CN=127.0.0.1

On a real network, add -servername with the site’s hostname, and compare the issuer with the one the site uses everywhere else. When the origin reset the intercepting proxy’s own handshake, curl never saw a reset at all. It saw a certificate it could not match: curl: (60) SSL: no alternative certificate subject name matches target IPv4 address '127.0.0.1'. Behind that, fetched with -k in the lab only, was Squid’s 503 Service Unavailable carrying X-Squid-Error: ERR_SECURE_CONNECT_FAIL 54. The reset itself appeared in just one place, the proxy’s log: ERR_SECURE_CONNECT_FAIL/SQUID_TLS_ERR_CONNECT+TLS_IO_ERR=5+errno=54. Behind TLS interception, the person who runs the proxy holds the evidence, so ask them for the log line. Turning off certificate checks only hides the symptom.

5. The transfer was cut part-way through the body

A server that sent 50,000 bytes of a declared 100,000-byte body and then reset produced curl: (56) Recv failure: Connection reset by peer. requests raised ChunkedEncodingError wrapping ConnectionResetError(54), although the response was not chunked at all; the name is misleading. Node’s fetch raised TypeError: terminated with cause read ECONNRESET. The same cut with a FIN looks different: curl printed (18) end of response with 50000 bytes missing and requests reported IncompleteRead(50000 bytes read, 50000 more expected).

Mid-body resets come from a server process that died or restarted, or from an intermediary that enforces a time or size limit. Retry idempotent downloads. For large files, resume rather than restart: if the server sends Accept-Ranges: bytes, a Range request (RFC 9110) picks up where the reset left off.

6. A large upload the server refused early

A server can reject an upload as soon as it sees the headers, with 413 for size or 401 for credentials, and close without reading the body. Under RFC 1122 that close sends a RST, because your unread body counts as lost data. We declared a 200,000,000-byte body on a raw socket, kept sending, and let the server answer 413 and close:

  • Linux 6.8, three trials: send() failed with ConnectionResetError(104, 'Connection reset by peer') after 2,555,904 to 2,681,856 bytes. The 413 was still readable afterwards.
  • macOS 26.6.2, three trials: send() failed with BrokenPipeError(32, 'Broken pipe') after 655,360 to 720,896 bytes. The 413 was still readable.

The higher-level clients handled it. On macOS, curl 8.23.0 returned the 413 in 6 of 6 attempts, and requests 2.32.3 and httpx 0.27.2 in 4 of 4 each. curl had an advantage it applied on its own: it sent Expect: 100-continue for the 20 MB body, which lets a server refuse before the body is sent. If your own code hits resets on uploads, read the response anyway once the send fails, send Expect: 100-continue for large bodies, and check the server’s size limit.

7. Restarts, reboots and forgotten NAT state

Long-lived idle connections suffer most here: WebSockets, database pools, long polls, tunnels that sit quiet. The far host restarts, or a NAT or stateful firewall drops the mapping after its own idle period, and the next packet meets a peer with no record of the connection. TCP’s own keep-alive will not save you by default. RFC 1122 says the keep-alive interval “MUST default to no less than two hours”, which is far longer than most middlebox idle timers. Send application-level pings, or enable TCP keep-alives with a short interval, at a period below the shortest idle timeout on the path, and write reconnect logic that expects to need it.

8. A reset injected by the network

When neither end’s logs explain the reset, capture packets on both sides. A RST that arrives at the client but was never sent by the server was injected by something between them. Weaver and colleagues detected injected resets through the races an out-of-path device cannot avoid: data packets from the real sender still arriving after the RST, or a RST whose sequence number lags data the receiver has already seen. Confirm by testing from a different network path. The fix belongs to whoever operates the device.

9. You are the peer: resets in your own server logs

Servers log resets when clients hang up mid-response: a user closes the tab, a scraper hits its timeout, a mobile client loses signal. We had a server write a 50 MB response to a client that read 1,000 bytes and closed. On Linux the server’s send() failed with ConnectionResetError(104, 'Connection reset by peer') after 2,621,440 bytes. On macOS it was BrokenPipeError(32, 'Broken pipe') after 524,288 bytes, in both of two runs. That is the usual difference between the two messages in server logs: same event, different platform and timing. Log these at debug level and alert on the rate, not on single events. If you run a reverse proxy, its log tells you which side of it hung up.

Cloudflare: 520, 521 and the 1xxx codes

Cloudflare’s 1xxx errors are HTTP responses, not resets. Cloudflare’s documentation sends them with a normal status code, 403 or 429, and puts the 1xxx number in the HTML body. A 1020 page therefore proves the opposite of a reset: TCP and TLS both worked, and a rule refused the request. The 5xx codes describe Cloudflare’s connection to the origin, which is where a reset becomes visible to the site owner.

Code HTTP status What Cloudflare’s docs say it means If you are the visitor If you own the site
520 520 The origin returned an empty, unknown or unexpected response. The docs’ log section includes an origin that “dropped the TCP connection before sending response headers”. Nothing to change on your side. Try later or tell the owner. Check origin error logs for crashes, confirm Cloudflare IPs are not blocked, check the origin’s HTTP/2 setup. In Logpush, OriginResponseStatus 0 with CacheStatus miss or expired marks a failed origin connection.
521 521 The origin refuses connections from Cloudflare. Nothing to change on your side. Allow Cloudflare’s IP ranges in the origin firewall; make sure the origin listens on 80 or 443 to match the SSL/TLS mode.
1006, 1007, 1008, 1106 403 Your IP address has been banned by the site’s settings. Ask the site owner to review their settings or allow your address. Cloudflare’s docs say its support cannot override a customer’s security settings. Review IP rules and Zone Lockdown.
1010 403 The owner banned access based on the browser’s signature. Contact the site owner; Cloudflare points to Whois if no contact is listed. Review Browser Integrity Check in the Security Settings.
1015 429 You are being rate limited. Wait. Cloudflare warns that repeated attempts in a short period may extend the block. Review rate limiting thresholds; Cloudflare suggests a longer counting period, such as 10 seconds, for rules with very short windows.
1020 403 A security rule with a Block action matched the request. Send the owner a screenshot of the error, including the Ray ID. Search Security Events for the Ray ID or client IP, then adjust the rule that blocked it.

Through a proxy, the address Cloudflare evaluates is the proxy’s exit, so IP and rate rules apply to that exit, not to you. These are the site owner’s decisions, and this page does not cover ways around them. The status-code side of the same problem is in 403 vs 407 vs 429.

Cause-to-fix table

What you see Likely cause Check Fix
Occasional ECONNRESET or socket hang up, often after an idle gap Reused keep-alive connection the server had closed Was it a reused connection? Node exposes req.reusedSocket Retry idempotent requests once; keep the client’s idle timeout below the server’s
curl (56) right after Request completely sent off, every time Server or a rule aborts the request Same client against /robots.txt; same request from another network Server error log if it is yours; otherwise slow down and contact the operator
curl (35) Recv failure after Client hello Handshake refused by a filter, wrong port or unconfigured name openssl s_client -servername from two networks Correct host and port; network administrator; server TLS configuration
Reset through a proxy, before the CONNECT 200 Proxy or the path to it refused you curl -v -x against a trusted endpoint Proxy address, credentials or provider
unexpected eof or ERR_CONNECTION_CLOSED after the CONNECT 200 Target failed behind the proxy Same target without the proxy, or through another exit Depends on the target; the proxy is working
CONNECT tunnel failed, response 407 or 503 Authentication or upstream refusal; not a reset Read the status Fix credentials; check the target port
Certificate issued by an unexpected CA TLS interception openssl s_client ... | openssl x509 -noout -issuer Ask the proxy’s operator for their log; install their CA properly rather than disabling checks
Reset after part of the body Transfer cut by the server or an intermediary Bytes received against Content-Length Retry; resume with Range
Reset or broken pipe while uploading Server refused the upload early Is a 413 or 401 readable after the failure? Expect: 100-continue; check size limits
Resets on long-idle connections Restart, reboot or expired NAT state How long was the connection idle? Application pings or short keep-alives; reconnect logic
Resets neither end can explain Injected by a device on the path Packet capture on both ends The network’s operator
Resets in your own server logs Clients hanging up Rate over time Log, do not page on single events

How this was tested

Everything ran on 21 October 2026, on macOS 26.6.2 (Darwin 25.6.0, Apple silicon), over the loopback interface. The errno, reset, upload and hang-up checks were repeated on a Linux 6.8.0 server over its own loopback, with Python 3.10.12 and curl 7.81.0, which printed the same (56) Recv failure: Connection reset by peer. Clients: curl 8.23.0 with OpenSSL 4.0.3, plus the system curl 8.7.1 (SecureTransport, LibreSSL 3.3.6), which printed identical reset messages; Python 3.9.6 with requests 2.32.3, urllib3 2.3.0, httpx 0.27.2 and PySocks 1.7.1; Node 24.2.0 with undici 7.10.0; Go 1.24.4; Java 17.0.15; Chrome 155.0.8059.85 in headless mode, read through the DevTools Protocol. The proxy was Squid 6.13 with basic authentication and ssl-bump enabled on a separate port.

The test servers were small Python 3.15.0 socket servers bound to 127.0.0.1. One aborts with SO_LINGER set to zero after reading the request (RST). One closes normally (FIN). One answers 413 and closes with the body unread. One cuts a 100,000-byte body at 50,000 bytes, by RST or by FIN. One resets right after the TLS ClientHello. A keep-alive server closes idle connections after 1.0 s without a Keep-Alive header, and another serves the first request on each connection and resets the second. Sample sizes sit next to each figure above. Loopback has no network delay or loss, so the keep-alive counts show the mechanism on this setup and should not be read as rates for a real network.

Frequently asked questions

What does "connection reset by peer" mean?
The other end of your TCP connection sent a RST segment, aborting the connection instead of closing it normally. Your operating system reports this as ECONNRESET, and anything in flight is lost. Through a proxy, the other end is the proxy, not the website.
What does errno 104 mean? Is it an HTTP status code?
No. 104 is the Linux error number for ECONNRESET, "Connection reset by peer". The same error is 54 on macOS and WSAECONNRESET, 10054, on Windows. HTTP has no status code 104.
What is the difference between connection reset and connection refused?
Refused means nothing accepted the connection, usually because no service listens on that host and port; curl exits with code 7. Reset means a connection existed and was then aborted. They have different causes, so check which one you have before changing anything.
Why do I get connection reset by peer only through a proxy?
Because the reset most likely comes from the proxy or the path to it. In our Squid 6.13 tests a reset sent by the target never reached the client as a reset: curl saw the TLS stream end early and Chrome saw ERR_CONNECTION_CLOSED. Run curl -v through the proxy and note whether the reset arrives before or after "CONNECT tunnel established".
Should I retry after ECONNRESET?
Retry once, on a new connection, and only for idempotent requests such as GET. That clears the keep-alive race, where the server closed a pooled connection just as you reused it. Do not retry a POST automatically; RFC 9110 advises against it unless you know the request is safe to repeat.
Is ERR_CONNECTION_RESET the same error?
Yes, it is Chrome's name for the same TCP event. Chromium's error list defines ERR_CONNECTION_RESET (-101) as corresponding to a TCP RST, and ERR_CONNECTION_CLOSED (-100) as corresponding to a TCP FIN.
What is the difference between connection reset by peer and broken pipe?
Both mean the other end has gone. A reset is usually reported when you read, a broken pipe when you write to a connection the peer has already closed. In our tests the same event, a server writing to a client that hung up, showed up as ConnectionResetError(104) on Linux and BrokenPipeError(32) on macOS.

Sources

  1. RFC 9293: Transmission Control Protocol, section 3.5.2, Reset Generation
  2. RFC 1122 section 4.2.2.13: Closing a Connection
  3. RFC 1122 section 4.2.3.6: TCP Keep-Alives
  4. RFC 2525 section 2.17: Failure to RST on close with data pending
  5. Linux kernel source: net/ipv4/tcp.c, tcp_close()
  6. RFC 9110 section 9.2.2: Idempotent Methods
  7. RFC 9110 section 15.5.8: 407 Proxy Authentication Required
  8. RFC 9110 section 14: Range Requests
  9. RFC 1929: Username/Password Authentication for SOCKS V5
  10. Node.js documentation: Common system errors (ECONNRESET)
  11. Node.js documentation: request.reusedSocket
  12. Node.js documentation: server.keepAliveTimeout
  13. curl: libcurl error codes
  14. Chromium source: net/base/net_error_list.h
  15. Microsoft: Windows Sockets error codes (WSAECONNRESET 10054)
  16. nginx documentation: reset_timedout_connection
  17. nginx documentation: keepalive_timeout
  18. nginx documentation: return (non-standard code 444)
  19. nginx source: src/http/ngx_http_upstream.c
  20. AWS: Application Load Balancer attributes, connection idle timeout
  21. urllib3 documentation: Retry
  22. Weaver, Sommer and Paxson: Detecting Forged TCP Reset Packets (NDSS 2009)
  23. tcpdump: pcap-filter manual page
  24. Squid configuration: ssl_bump
  25. Cloudflare documentation: Error 520
  26. Cloudflare documentation: Error 521
  27. Cloudflare documentation: Cloudflare 1xxx errors
  28. Cloudflare documentation: Error 1006, 1007, 1008 or 1106
  29. Cloudflare documentation: Error 1010
  30. Cloudflare documentation: Error 1015
  31. Cloudflare documentation: Error 1020

Read this page as Markdown · Quote it freely under CC BY 4.0 with a link back.