Connection reset by peer through a proxy: who sent it

Connection reset by peer through a proxy, tested: what curl, Python and Node print at each stage, proxy or target, and which resets are safe to retry.

Metal box with a connection reset panel, finding which hop reset the proxy connection
Quick summary · TL;DR
  1. Run curl -v once and see whether the reset lands before or after CONNECT tunnel established. Before it, the proxy refused you and the target never saw a byte. After it, either side could have done it, so request a known-good URL through the same proxy to find out.
  2. A target that resets often shows up as a clean close, not a reset. proxy.py closed its side normally, so curl printed (18) transfer closed with 990 bytes remaining, or (52) Empty reply from server, with no ECONNRESET anywhere in the output.
  3. Don't trust requests when it says Unable to connect to proxy. It printed that for a reset from the target after the tunnel was open and the request had been delivered, and urllib3 then resent the POST four times under Retry(total=3).
  4. Resets that only appear under load are usually a connection or rate limit. The output matches a plain proxy refusal, and a short retry loop made it worse, while capping concurrency at the limit got 5 of 5 through.

If you got Connection reset by peer through a proxy, something on the path sent a TCP reset and threw the connection away mid-conversation. In a connection reset by peer proxy error your peer is always the proxy, so the reset arrived from the proxy’s address even when the target caused it. What matters is the stage. A reset before the CONNECT reply is the proxy’s own refusal, and one after it can be either side.

That stage also tells you whether a retry is safe, which is the part most fixes skip. The tests below cover each stage, plus stale pooled sockets, idle timeouts, port mix-ups and connection limits, and all of it ran on 6 November 2026:

  • macOS 26.6.2, curl 8.7.1 with LibreSSL 3.3.6
  • requests 2.34.2 with urllib3 2.8.0, httpx 0.28.1 and aiohttp 3.14.5 on Python 3.12.13
  • Node 24.14.1, fetch and the http module, with NODE_USE_ENV_PROXY=1
  • Scripted proxies and targets on 127.0.0.1 that reset on cue, and proxy.py 2.4.10 as real proxy software

Linux and Windows weren’t tested. Their error numbers below come from their own error tables.

What connection reset by peer proxy errors mean

A reset is one TCP packet with the RST flag set. It says “this connection no longer exists, stop sending”, with no reason attached, and your socket call fails at once. The name changes with the OS:

  • macOS: ECONNRESET is 54 in sys/errno.h. Python printed [Errno 54] Connection reset by peer and Node printed read ECONNRESET with errno=-54.
  • Linux: ECONNRESET is 104 in the kernel’s asm-generic/errno.h (checked 2026-11-06), so the same failure reads [Errno 104].
  • Windows: WSAECONNRESET is 10054 in Microsoft’s Winsock error table (page updated 2021-08-19), described there as a connection “forcibly closed by the remote host”.

A clean close is different. That’s a FIN, and clients report it with words like “Empty reply”, “Server disconnected” or “other side closed”. The difference matters more through a proxy than anywhere else, as the next sections show.

Find the stage with curl -v

Run the failing URL through curl with -v and look at the last lines before the error. The curl proxy guide covers the flags. These are the lines curl printed in the lab:

Where it brokeLast lines from curl -vcurl error
Before the CONNECT replyEstablish HTTP proxy tunnel to 127.0.0.1:18443, then Recv failure: Connection reset by peer(56) Recv failure: Connection reset by peer
After CONNECT tunnel established, response 200LibreSSL/3.3.6: error:02FFF036:system library:func(4095):Connection reset by peer(35) Recv failure: Connection reset by peer
Partway through the TLS handshakeSame two lines as the row above(35) Recv failure: Connection reset by peer
After TLS, before or during the response, RST passed onLibreSSL SSL_read: ... Connection reset by peer, errno 54(56) Recv failure: Connection reset by peer
Mid-body, proxy closed normally< HTTP/1.1 200 OK, then nothing(18) transfer closed with 990 bytes remaining to read
Before the response, proxy closed normallySSL connection using TLSv1.3, then nothing(52) Empty reply from server

Start with the first row, the easy one. curl never got a reply to CONNECT, so the target wasn’t contacted yet, and the proxy (or a firewall in front of it) sent the reset. Connection limits, rate limits and an HTTP request to a SOCKS port all print exactly that row, which is why it’s the row to check first.

Both exit 35 rows look identical. A proxy that resets right after the 200 and one that cuts the handshake halfway printed the same text, so curl can’t separate “the proxy dropped the tunnel” from “the target dropped TLS”. Exit 35 does tell you no HTTP request was sent yet, because the request only goes out once TLS is done. That’s the stage where you can retry anything, POST included.

Proxy reset or target reset

Once you see CONNECT tunnel established, response 200, the proxy is a relay. A target can reset its side, and what you see depends on how the proxy closes yours.

  • The proxy passed the RST on. A scripted relay that answered a target reset with its own reset gave the same curl output as a direct request to the target: (56) Recv failure: Connection reset by peer, errno 54.
  • The proxy closed normally. proxy.py 2.4.10 closed its side with a FIN when the target reset. curl then printed (18) transfer closed with 990 bytes remaining to read mid-body, and (52) Empty reply from server before the response, on both an https:// and an http:// target.

So a target that resets often doesn’t produce a reset at all on your side. If you only grep logs for ECONNRESET, you’ll miss the cases where proxy software turned the target’s reset into a clean but early close.

To place it, request a known-good URL through the same proxy. If that works, the proxy path is fine and the target (or its rate limiting) is resetting. A plain request to the target that works without the proxy and fails through it points the other way, at the proxy. The live guide to proxy error codes covers the cases where the proxy answers with a status instead.

What each client prints

The same six faults, as each library reported them. Strings are copied from the runs and trimmed only where marked with three dots.

Python (requests 2.34.2, httpx 0.28.1, aiohttp 3.14.5):

Faultrequestshttpxaiohttp
Reset before CONNECT replyConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))ReadError: [Errno 54] Connection reset by peerClientOSError: [Errno 54] Connection reset by peer
Reset after 200 or mid-TLSSame as aboveConnectError: [Errno 54] Connection reset by peerClientConnectorError: Cannot connect to host 127.0.0.1:18443 ssl:... [Connection reset by peer]
Target reset before responseProxyError: ... (Caused by ProxyError('Unable to connect to proxy', RemoteDisconnected('Remote end closed connection without response')))RemoteProtocolError: Server disconnected without sending a response.ClientOSError: [Errno 54], or ServerDisconnectedError: Server disconnected after a clean close
Target reset mid-bodyChunkedEncodingError with IncompleteRead(10 bytes read, 990 more expected), or BrokenPipeError(32, 'Broken pipe') when the RST was passed onRemoteProtocolError: peer closed connection without sending complete message body (received 10 bytes, expected 1000)ClientPayloadError: Response payload is not completed: ... (received 10 of 1000 bytes)

The requests row for a target reset is the one that sends people the wrong way. The tunnel was open, TLS was done and the target had the request, yet requests reported Unable to connect to proxy. Setup lives in the Python requests proxy guide. Here the point is to stop reading that wording as proof the proxy is down.

Node 24.14.1:

Faultfetchhttp module
Any reset before the response, RST receivedTypeError: fetch failed, cause Error: read ECONNRESET, code ECONNRESET, errno -54Error: read ECONNRESET, code ECONNRESET
Clean close before the responseTypeError: fetch failed, cause SocketError: other side closed, code UND_ERR_SOCKETError: socket hang up, code ECONNRESET
Reset mid-bodyTypeError: terminated, cause Error: read ECONNRESETError: read ECONNRESET
Clean close mid-bodyTypeError: terminated, cause SocketError: other side closedan aborted event on the response, plus an error with message aborted and code ECONNRESET if you listen for one

Look at the second row. Node’s http module labels a clean close socket hang up with code ECONNRESET, although no reset packet was involved. If your error handler keys on code === 'ECONNRESET', it’s catching both cases. Node’s fetch only ever printed “fetch failed”, so log err.cause or you lose the whole story.

Keep-alive and idle timeouts

Two kinds of idle trouble show up as resets, and they need opposite fixes.

Stale keep-alive connections

The classic report is “the first request works, the next one after a pause fails”. A pooled client keeps the connection to the proxy open, the proxy drops it for being idle, and the client writes into a socket that’s already gone.

Two cases behaved very differently. When the proxy closed an idle connection (by FIN or by RST) a second before the next request, every client noticed and opened a new one. requests, httpx, aiohttp, fetch and Node http all returned 200 on the second request, on both http:// and https:// targets.

The failure comes when the close and the next request cross on the wire. A scripted proxy reset the reused connection the moment the second request arrived, and this is what each client did:

  • curl retried by itself: Connection died, retrying a fresh connect (retry count: 1), then 200. It did that for a POST too.
  • requests raised ProxyError: ... ProxyError('Unable to connect to proxy', ConnectionResetError(54, 'Connection reset by peer')) with default settings.
  • httpx raised ReadError: [Errno 54] Connection reset by peer.
  • aiohttp quietly resent a GET and returned 200, but raised ClientOSError: [Errno 54] for a POST.
  • Node fetch raised fetch failed with read ECONNRESET for GET and POST alike.
  • Node http raised read ECONNRESET with req.reusedSocket set to true.

That last flag is the hint Node gives you. The Node http docs (checked 2026-11-06) describe this exact race under request.reusedSocket and suggest retrying idempotent requests when it’s set. The other fix is on your side of the pool: keep your client’s idle timeout shorter than the proxy’s, so your client closes first.

Idle timeouts mid-request

An idle timeout can also hit a request that’s still in flight. A target took 3 seconds to answer and the proxy killed tunnels after 1 second of silence:

  • With a scripted proxy that reset: curl (56) Recv failure, requests ProxyError with Unable to connect to proxy, httpx Server disconnected without sending a response., aiohttp ClientOSError: [Errno 54], Node read ECONNRESET.
  • With proxy.py started with --timeout 1: curl (52) Empty reply from server, requests the same ProxyError, httpx the same disconnect, aiohttp ServerDisconnectedError: Server disconnected.

Retrying this one only adds load. A retry loop sent the slow request to the target four times, every attempt failed at the 1 second mark, and the loop gave up after about 6 seconds (6.07 s and 5.83 s in two runs). aiohttp alone also sent it twice on every call. The fix is a longer idle timeout on the proxy, a streaming response that keeps bytes moving, or a faster endpoint.

Protocol mismatch on the port

Pointing a client at the wrong kind of port is a common cause of resets, but proxy.py, the one real proxy tested, hung instead of resetting.

  • HTTP proxy URL on a SOCKS5 port. A scripted SOCKS5 server read the first byte, saw it wasn’t version 5 and closed with the rest of the request unread. The kernel sends a reset for that, as RFC 1122 section 4.2.2.13 (October 1989) recommends when a socket closes with data pending. Every client printed a reset at the “before CONNECT reply” stage, and curl gave (56) Recv failure: Connection reset by peer.
  • TLS to a plain HTTP proxy port. proxy.py didn’t reset. It waited, and curl ended with (28) Connection timed out after 10009 milliseconds. A scripted plain port gave (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:19000.
  • SOCKS client on an HTTP proxy port. proxy.py hung again, (28) Connection timed out after 10008 milliseconds. The scripted port gave (97) connection to proxy closed.
  • TLS to a plain HTTP target through the tunnel. Python’s http.server answered the handshake with text, and curl printed (35) LibreSSL/3.3.6: error:1404B42E:SSL routines:ST_CONNECT:tlsv1 alert protocol version, both through proxy.py and direct.

If the reset is instant and happens before the CONNECT reply, check that the port and the scheme in your proxy URL match. SOCKS5 failures in more depth live in the SOCKS5 troubleshooting guide, and the browser side of a refused tunnel is covered in ERR_TUNNEL_CONNECTION_FAILED.

Connection limits and rate limits

Some proxies and firewalls enforce limits by accepting the connection and resetting it. A scripted proxy allowed 2 concurrent tunnels, and another allowed 3 new connections per 2 seconds:

  • 5 parallel curl requests against the limit of 2: two got 200 OK, three got (56) Recv failure: Connection reset by peer.
  • 6 quick requests against the rate limit: the first three got 200, the fourth to sixth got the same (56).

Their output matches the first row of the stage table, so a reset that appears only under load, and goes away when you run one request, points at a limit. A short retry loop made it worse. With waits of 0.25, 0.5 and 1 second, 3 of 5 jobs still failed against the concurrency limit, and the proxy absorbed 14 connections and 12 resets.

Two changes fixed it in the same lab:

  1. A semaphore of 2 in the client, matching the limit: 5 of 5 succeeded in 9.06 s, with 5 connections and no resets.
  2. For the rate limit, a random wait of 1 to 2 seconds that doubles each try: 6 of 6 succeeded in about 5 seconds (4.87 s and 5.07 s in two runs), after 6 resets.

The proxy performance tuning guide covers sizing concurrency to a pool.

Which resets are safe to retry

A reset doesn’t tell you whether the target already acted on your request. The test target counted a POST, then reset before answering, and here’s what the usual retry settings did with it:

  • urllib3 Retry(total=3, backoff_factor=0.2) with its default method list, which leaves POST out, still sent the POST four times, and the target processed all four. In urllib3 2.8.0’s retry.py only the read-error branch checks the method list, and this reset wasn’t filed as one. requests reported it as Unable to connect to proxy, and urllib3 counted it against the other budget, which the urllib3 docs (checked 2026-11-06) say may follow a request that was already sent. Setting connect=0 or read=0 still gave four sends. Only other=0 stopped it at one.
  • curl --retry 3 didn’t retry exit 56 at all. Its man page counts only timeouts, FTP 4xx replies and HTTP 408, 429, 500, 502, 503 and 504 as transient. With --retry-all-errors it resent the POST three more times, and the man page itself warns that this option can send duplicate data.
  • aiohttp resent a GET once on its own after a reset before the CONNECT reply, after a target reset and on a reused socket. It never resent a POST.
  • Node fetch, Node http and httpx (with retries=3 on the transport) didn’t retry any of these resets.

That leaves a simple rule, by stage:

ResetDid the target get the request?Retry
Before the CONNECT reply, including limitsNoYes, any method, with backoff or a lower concurrency
After the 200, during TLS (curl exit 35)No, the request isn’t sent until TLS is doneYes, any method
Reused pooled socketUnknownIdempotent methods only
After the request went out, before or during the responsePossibly, and it may have acted on itIdempotent methods, or a POST with an idempotency key the API honours
Idle timeout on a slow targetYes, it’s still workingNo, fix the timeout

Your code usually can’t see the stage, so the safe default is to retry on method. This wrapper ran against the lab: GET was retried after a reset before CONNECT (4 attempts in about 2 s), a reset POST that the target had processed went out once, and a GET on a reset reused socket came back 200.

import time
import requests

IDEMPOTENT = {"GET", "HEAD", "OPTIONS", "PUT", "DELETE"}

def send(session, method, url, attempts=4, **kw):
    for i in range(attempts):
        try:
            return session.request(method, url, timeout=(5, 30), **kw)
        except (requests.ConnectionError, requests.exceptions.ChunkedEncodingError):
            safe = method in IDEMPOTENT or "Idempotency-Key" in kw.get("headers", {})
            if not safe or i == attempts - 1:
                raise
            time.sleep(0.25 * 2 ** i)

Leave the adapter at its default of no retries when you use it, or set read=0 and other=0 on its Retry. Otherwise urllib3’s own retry runs underneath and can resend the POST anyway, as the other budget did above. ProxyError is a subclass of ConnectionError, so the except catches the “Unable to connect to proxy” case too.

For Node, check the cause code, because fetch wraps everything in “fetch failed”. It retried a reset GET (4 attempts) and a GET on a reset reused socket (200), and sent a processed POST once:

const IDEMPOTENT = new Set(['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE']);
const RESET_CODES = new Set(['ECONNRESET', 'UND_ERR_SOCKET', 'EPIPE']);

async function send(url, init = {}, attempts = 4) {
  const method = (init.method || 'GET').toUpperCase();
  for (let i = 0; ; i++) {
    try {
      return await fetch(url, { ...init, signal: AbortSignal.timeout(30000) });
    } catch (err) {
      const code = err.cause?.code;
      if (!RESET_CODES.has(code) || !IDEMPOTENT.has(method) || i === attempts - 1) throw err;
      await new Promise(r => setTimeout(r, 250 * 2 ** i));
    }
  }
}

Run it with NODE_USE_ENV_PROXY=1 and HTTPS_PROXY=http://USERNAME:PASSWORD@HOST:PORT set, which is how Node 24 picked up the proxy here. On rotating residential proxies set to a new IP per request, the retry opens a fresh connection and gets a new IP, and proxymint’s tiers all take the same username and password login over HTTP or SOCKS5.

Fix connection reset by peer proxy errors

Start with one curl -v run against the failing URL. A reset before CONNECT tunnel established means the target never saw you. Check the port and scheme, then look for a limit by running one request at a time. A failure that only shows up under load wants capped concurrency and a retry with backoff.

A reset after the 200 needs one more request, to a known-good URL through the same proxy. If that works, the target is resetting you, and a target that resets every attempt usually wants a slower rate, not more retries. Requests that pause before they fail are the idle-timeout case. Compare the gap with the proxy’s idle timeout and shorten your pool’s idle time.

Whatever the stage, retry GET and other idempotent calls, and send a POST twice only when the API gives you an idempotency key.

Frequently asked questions

Something on the path sent a TCP RST and dropped the connection without a reason. Through a proxy that packet always arrives from the proxy's address. Either the proxy refused or closed you, or it passed on a reset from the target, and curl -v shows which stage it hit, which narrows it down.

It depends on where curl -v shows the reset. Before CONNECT tunnel established it's the proxy or a firewall in front of it, because the website wasn't contacted yet. After the 200, either one can be responsible, so request a URL you know works through the same proxy. When that succeeds, the website is resetting you.

Read err.cause on fetch errors and req.reusedSocket on http errors first. A reset on a reused socket is the keep-alive race, and Node's docs suggest retrying idempotent requests when reusedSocket is true. A reset on every request points at the proxy URL, the port or a limit, and retrying won't help there.

requests 2.34.2 with urllib3 2.8.0 used that wording for a reset that came after the tunnel was open and TLS was done, so it doesn't prove the proxy is down. Check the inner text: RemoteDisconnected or ConnectionResetError after a working tunnel means the target or the proxy dropped the connection once the request was sent.

It is for GET, HEAD, PUT and DELETE, and for anything that failed before the CONNECT reply or during TLS, since the request wasn't sent yet. A POST that reset after it went out may already have been processed, and in the test it was. Retry that only with an idempotency key, and check that your library's built-in retry doesn't resend it for you.

They're the same error, ECONNRESET, on different systems. macOS uses 54, Linux uses 104 and Windows reports WSAECONNRESET as 10054. A Python traceback shows [Errno 54] on a Mac and [Errno 104] on Linux, and Node shows errno -54 on a Mac next to code ECONNRESET.

Yes, and it looks exactly like a proxy refusal. A test proxy with a limit of 2 tunnels reset three of five parallel requests before the CONNECT reply. Running the same jobs through a semaphore of 2 got all five through with no resets, which a retry loop with short waits didn't manage.

Researched and drafted with AI tools, then checked against our publishing rules before it went live: 5 outside links, 6 links to other proxymint pages, no prices and a fact-check pass against our product records. How we write.