On this page 9 sections
- What the verbose output shows
- The same failure in other clients
- Three checks before you change anything
- Causes on the server side, in the order worth checking
- 1. The handler crashed before writing anything
- 2. A server-side timeout fired first
- 3. A kept-alive connection was closed as you reused it
- 4. Plain HTTP sent to a TLS port
- 5. Over HTTPS, the server closed after the handshake
- Proxy-specific causes
- 6. The proxy closed the connection instead of answering
- 7. The origin’s empty reply came through the tunnel
- 8. Something in the path intercepts TLS
- Scheme mix-ups at the proxy usually give a different error
- Containers: a lead we did not reproduce
- Errors that look like 52 but are not
- Behind Cloudflare: 520 and the 10xx codes
- Cause-to-fix table
- How this was tested
curl: (52) Empty reply from server
curl opened the connection, sent the whole request, and the other end closed the connection without sending back one byte. No status line, no headers, nothing to parse. libcurl names this condition CURLE_GOT_NOTHING, and the curl command exits with code 52.
That rules a lot out at once. DNS resolved. The TCP connection opened. On an https:// URL the TLS handshake finished. Whatever broke happened after your request arrived, on whichever machine held the other end of the socket. With no proxy, that is the server. With a proxy and an http:// URL, it can be the proxy. With a proxy and an https:// URL it is usually something past the proxy, for a reason explained in the proxy section below.
Every output on this page was captured on a test machine against local servers and a local Squid proxy. Versions are listed with each capture and in the test notes at the end.
What the verbose output shows
Run the request again with -v. This is curl 8.23.0 against a Python server whose handler throws an exception:
$ curl -v http://127.0.0.1:25201/
* Trying 127.0.0.1:25201...
* Established connection to 127.0.0.1 (127.0.0.1 port 25201) from 127.0.0.1 port 58355
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 127.0.0.1:25201
> User-Agent: curl/8.23.0
> Accept: */*
>
* Request completely sent off
* Empty reply from server
* shutting down connection #0
curl: (52) Empty reply from server
Two lines carry the diagnosis. Request completely sent off proves the request left your machine in full. Empty reply from server is curl reading end-of-stream where a status line should have been. If you see the first line and not a < HTTP/1.1 line after it, the problem is on the far side.
The same failure in other clients
The event has a different name in every HTTP stack. When a colleague reports one of these and you see another, you are probably looking at the same thing. All of these came from the same server and the same request:
| Client | Version | What it reports |
|---|---|---|
| curl (Homebrew build) | 8.23.0, OpenSSL 4.0.3 | curl: (52) Empty reply from server |
| curl (macOS system build) | 8.7.1, SecureTransport | curl: (52) Empty reply from server |
| Python requests | 2.32.3, urllib3 2.3.0 | ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) |
| Python httpx | 0.27.2 | httpx.RemoteProtocolError: Server disconnected without sending a response. |
| Node fetch (undici) | Node 24.2.0 | TypeError: fetch failed, cause SocketError, code UND_ERR_SOCKET, “other side closed” |
| Node http.get | Node 24.2.0 | Error: socket hang up, code ECONNRESET |
| Google Chrome | 155.0.8059.85 | net::ERR_EMPTY_RESPONSE, page text “127.0.0.1 didn’t send any data.” |
Python documents RemoteDisconnected as the case where reading the response returns no data because the remote end closed. Chromium’s net_error_list.h defines ERR_EMPTY_RESPONSE as error -324, the server closing the connection without sending any data. One trap: Node labels the event ECONNRESET even here, where the server closed normally and never sent a TCP reset. Do not read that code literally.
Three checks before you change anything
Time it. The moment of the close tells you what kind of failure it was.
$ curl -sS -o /dev/null -w 'exit_after=%{time_total}s\n' http://127.0.0.1:25202/
curl: (52) Empty reply from server
exit_after=1.504138s
A close within a few milliseconds means something rejected the request as soon as it read it: a crash, a protocol mismatch, a gateway refusing. A close at a round number means a timer fired. In our Node test the close came at a median of 1.501 seconds across 10 runs, against a configured timeout of 1,500 ms. If your failures cluster at 30.0 or 60.0 seconds, go and find the component configured with that number.
Take the proxy out. Send the identical request with --noproxy '*', which also overrides any proxy picked up from environment variables. If the error disappears, the proxy path is involved. If it stays, the server is.
Check whether the port speaks TLS. A plain HTTP request to a TLS port is one of the quickest ways to get a 52.
$ openssl s_client -connect 127.0.0.1:25244 -brief </dev/null
Connecting to 127.0.0.1
depth=0 CN=localhost
verify error:num=18:self-signed certificate
CONNECTION ESTABLISHED
Protocol version: TLSv1.3
If you get a certificate back, that port wants https://.
Causes on the server side, in the order worth checking
1. The handler crashed before writing anything
The server accepted the connection, read the request, and the code handling it died. An unhandled exception, a segfault, a worker killed by the out-of-memory killer or by a supervisor. Nothing gets written, the socket closes, and the client sees an empty reply. This is the reproduction used throughout this page, built on Python’s standard library:
# crash_server.py (Python 3.15.0)
import http.server
class Crash(http.server.BaseHTTPRequestHandler):
def do_GET(self):
raise RuntimeError("handler crashed before writing a response")
http.server.ThreadingHTTPServer(("127.0.0.1", 25201), Crash).serve_forever()
The server’s own log has the answer, stamped with the same second as the client error:
File ".../crash_server.py", line 6, in do_GET
raise RuntimeError("handler crashed before writing a response")
RuntimeError: handler crashed before writing a response
Fix: read the application log at the timestamp of the failure and fix the code path. A framework that catches the exception answers 500 instead, which is far easier to debug. A reverse proxy in front also changes what clients see: in our tests Squid 6.13 turned this exact empty reply into HTTP/1.1 502 Bad Gateway with X-Squid-Error: ERR_ZERO_SIZE_OBJECT 0. So if users behind your proxy report 502s while your own direct curl gets 52, it is the same crash.
2. A server-side timeout fired first
Some servers close a socket that has been quiet for too long, even when a request is in flight and the handler is still working. Node does this when you call server.setTimeout() and attach no 'timeout' listener. The Node documentation notes the default is 0, no timeout, since v13.0.0, so this only bites when someone set one.
// node_timeout_server.js (Node 24.2.0)
const http = require('node:http');
const srv = http.createServer((req, res) => { /* slow handler, never ends */ });
srv.setTimeout(1500);
srv.listen(25202, '127.0.0.1');
Result: curl: (52) Empty reply from server at 1.50 seconds, every time. Fix: either raise the timeout above your slowest legitimate response, or answer when it fires, so clients get a status code they can act on:
srv.on('timeout', (socket) => {
socket.end('HTTP/1.1 503 Service Unavailable\r\nContent-Length: 0\r\nConnection: close\r\n\r\n');
});
With that listener, the same request returned 503 at 1.50 seconds and curl exited 0. The principle carries over to any stack: a timeout should produce a 503 or 504, not silence.
3. A kept-alive connection was closed as you reused it
This is the intermittent kind, and the one that makes curl look fine while your application fails. HTTP clients keep idle connections open to reuse them. Servers close idle connections after their own keep-alive timeout, which in Node is 5,000 ms by default. If the client sends a request on a connection at the moment the server gives up on it, the request lands on a socket that is already closing.
To make the race reproducible, a test server answered the first request on each connection and closed the connection, without replying, when a second request arrived on it. curl 8.23.0 recovered on its own:
$ curl -v http://127.0.0.1:25203/a http://127.0.0.1:25203/b
...
< HTTP/1.1 200 OK
* Connection #0 to host 127.0.0.1:25203 left intact
* Reusing existing http: connection with host 127.0.0.1
* Request completely sent off
* Connection died, retrying a fresh connect (retry count: 1)
* shutting down connection #0
* Issue another request to this URL: 'http://127.0.0.1:25203/b'
...
< HTTP/1.1 200 OK
The libraries did not all do the same. Second request on a reused connection:
- requests 2.32.3: raised
RemoteDisconnected('Remote end closed connection without response'). - httpx 0.27.2: raised
RemoteProtocolError: Server disconnected without sending a response. - Node fetch: returned 200.
- Node http.get with a keep-alive Agent:
socket hang up,ECONNRESET.
Fix: retry idempotent requests once on this specific error, and keep your client’s idle timeout shorter than the server’s. With requests, a urllib3 Retry on the adapter is enough. This passed three requests in a row against the same server:
# Python 3.9.6, requests 2.32.3, urllib3 2.3.0
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
s = requests.Session()
s.mount("http://", HTTPAdapter(max_retries=Retry(total=2, backoff_factor=0.2)))
s.mount("https://", HTTPAdapter(max_retries=Retry(total=2, backoff_factor=0.2)))
r = s.get("http://127.0.0.1:25203/", timeout=5)
Two limits. urllib3’s default retry methods are DELETE, GET, HEAD, OPTIONS, PUT and TRACE, so a POST is not retried, and in our test it raised the same error. That is deliberate: the server may have acted on the POST before it closed. And httpx’s HTTPTransport(retries=2) does not help here. The httpx documentation limits those retries to ConnectError and ConnectTimeout, and the second request still raised RemoteProtocolError. More on client setup in proxies in Python and proxies in Node.js.
4. Plain HTTP sent to a TLS port
curl http://example:443/, or any URL with the wrong scheme for its port. The server expects a TLS ClientHello and receives GET / HTTP/1.1. OpenSSL’s test server, openssl s_server from OpenSSL 4.0.3, logged this and closed:
error:0A00009C:SSL routines:tls_validate_record_header:http request
curl reported 52. A Python TLS server given the same mistake produced something else in 10 of 10 runs: curl: (56) Recv failure: Connection reset by peer. The likely difference is how each server closed. A TCP stack that closes a socket while received data is still unread should send a reset, per RFC 1122 section 4.2.2.13, and curl reports a reset as 56. We did not capture packets to confirm that. Either way: same mistake, two exit codes.
Fix: use https://. The openssl s_client check above settles it in one command. The reverse mistake, https:// to a plain HTTP port, fails earlier and louder: curl: (35) TLS connect error: error:0A00010B:SSL routines::wrong version number.
5. Over HTTPS, the server closed after the handshake
Causes 1 to 3 also happen on HTTPS servers, but the message depends on how the server closed the TLS session and which TLS library your curl uses. We tested two server behaviours against both curl builds:
| Server behaviour | curl 8.23.0 (OpenSSL 4.0.3) | curl 8.7.1 (SecureTransport) | requests / httpx |
|---|---|---|---|
| Sends TLS close_notify, then closes | (52) Empty reply from server |
(52) Empty reply from server |
RemoteDisconnected / RemoteProtocolError |
| Closes without close_notify (crash) | (56) OpenSSL SSL_read: OpenSSL/4.0.3: error:0A000126:SSL routines::unexpected eof while reading, errno 0 |
(52) Empty reply from server |
RemoteDisconnected / RemoteProtocolError |
So on an OpenSSL build of curl, a crashing HTTPS server often reports 56 with “unexpected eof while reading”. Treat it as the same family as 52 and work through the same causes.
Proxy-specific causes
With -x, which hop closed depends on the URL scheme. For an http:// URL the proxy reads your whole request and fetches the page itself, so it can answer with any status code it likes. For an https:// URL the proxy only sees CONNECT host:443. Once it replies 200 Connection established, it is moving encrypted bytes it cannot read (see HTTP CONNECT).
A proxy that does its job turns most upstream failures into a status code. This is what Squid 6.13 sent back in our tests:
| Situation | What the client got from Squid 6.13 |
|---|---|
Origin crashed, http:// URL |
502 Bad Gateway, X-Squid-Error: ERR_ZERO_SIZE_OBJECT 0 |
| Origin port closed | 503 Service Unavailable, X-Squid-Error: ERR_CONNECT_FAIL 61 |
No proxy credentials, http:// URL |
407, Proxy-Authenticate: Basic realm="lab-proxy" |
No proxy credentials, https:// URL |
curl: (7) CONNECT tunnel failed, response 407 |
| Origin closed with no reply, inside a CONNECT tunnel | curl: (52) Empty reply from server, passed straight through |
A 407 is never a 52. If credentials are the problem and the proxy follows the standard, you get a status line telling you so, as covered in 403 vs 407 vs 429. A 52 through a proxy means one of three things below.
6. The proxy closed the connection instead of answering
A gateway can refuse a request by closing the socket rather than by sending a 403 or 407. The reason may be bad credentials, a blocked destination, an exhausted balance or a concurrency limit; the client cannot tell which. We stood in for one with a 15-line Python script that reads the request head and closes the socket. Both curl builds reported the same thing:
$ curl -x http://127.0.0.1:25204 http://203.0.113.10/
curl: (52) Empty reply from server
$ curl -x http://127.0.0.1:25204 https://203.0.113.10/
curl: (56) Proxy CONNECT aborted
Note the split. When the proxy itself drops you, an https:// URL gives Proxy CONNECT aborted, not 52. So a 52 on an HTTPS URL through a proxy points past the proxy: the tunnel was built, and the empty reply came from further along.
Diagnose with three requests through the same gateway, one plain, one TLS, one with credentials removed:
P="http://user:pass@gw.example.net:8000"
curl -sS -o /dev/null -w 'plain %{http_code}\n' -x "$P" http://api.ipify.org
curl -sS -o /dev/null -w 'tls %{http_code}\n' -x "$P" https://api.ipify.org
curl -sS -o /dev/null -w 'noauth %{http_code}\n' -x http://gw.example.net:8000 http://api.ipify.org
If the echo service works and only your target fails, the gateway is refusing that destination or the target is refusing the gateway. If the request without credentials also returns 52 instead of 407, this gateway does not report auth failures with a status code. Check the username format first, since country and session parameters often live there (see proxy authentication). Then ask the provider what it logged. More flags in how to use a proxy with curl.
7. The origin’s empty reply came through the tunnel
Through Squid’s CONNECT tunnel to an HTTPS origin that closed without replying, curl printed this before failing:
> CONNECT 127.0.0.1:25245 HTTP/1.1
< HTTP/1.1 200 Connection established
* CONNECT tunnel established, response 200
* Empty reply from server
curl: (52) Empty reply from server
That response 200 line is your proof the proxy did its part. The proxy cannot convert the failure into a 502 because it never sees the HTTP inside the tunnel. Work through causes 1 to 5 against the origin. If the origin also fails when reached without the proxy, the proxy was never the issue.
8. Something in the path intercepts TLS
Corporate proxies and some security software decrypt HTTPS, inspect it, and re-encrypt it with their own certificate. This is TLS interception. Whether you get a 52 then depends on how the interceptor handles a failure upstream. In curl’s verbose output, check the issuer:
$ curl -sSv --cacert ca.pem -x http://127.0.0.1:25229 https://localhost:25245/ 2>&1 | grep -E 'issuer|Empty|curl:'
* issuer: CN=Lab Interception CA
* Empty reply from server
curl: (52) Empty reply from server
Direct to the same origin, the issuer was CN=localhost, the origin’s own certificate. An issuer you do not recognise means a third party terminated your TLS. With Squid 6.13 in ssl-bump mode, an origin that closed cleanly with no reply produced a 52 at the client in 10 of 10 runs, and Squid’s access log recorded TCP_MISS_ABORTED/000 0. An origin that crashed without close_notify produced a 502 with X-Squid-Error: ERR_READ_ERROR 0 instead. Without the interception CA installed, the client fails earlier with curl: (60) SSL certificate OpenSSL verify result: self-signed certificate in certificate chain (19).
Fix: repeat the request from a network without the interceptor. If it works there, ask whoever runs the interceptor to exclude the host, and send them the timestamp so they can find the matching log line.
Scheme mix-ups at the proxy usually give a different error
Pointing an http:// proxy URL at a port that speaks something else is an easy mistake, but in our tests it did not produce 52. Against Squid’s TLS proxy port (https_port), curl got (56) Recv failure: Connection reset by peer and Squid logged SQUID_TLS_ERR_ACCEPT+TLS_LIB_ERR=A00009C. SOCKS5 servers behave differently again. The microsocks source answers a greeting it does not recognise with two bytes, 0x05 0xFF, and closes. A stand-in sending exactly that got curl: (1) Received HTTP/0.9 when not allowed for an HTTP URL and (56) Proxy CONNECT aborted for HTTPS. Use socks5h:// for SOCKS ports and https:// for TLS proxy ports.
Containers: a lead we did not reproduce
A trigger that comes up in forum threads about this error is a published container port whose application listens only on 127.0.0.1 inside the container. Docker was not running on our test machine, so we have no capture for it. If it fits your setup, compare docker exec <container> ss -tlnp with the port you published, and bind the application to 0.0.0.0.
Errors that look like 52 but are not
| Message | What it means instead |
|---|---|
(56) Recv failure: Connection reset by peer |
The far end sent a TCP reset. It can come from the same causes as 52, for example a server closing with unread data. |
(56) ... unexpected eof while reading |
TLS closed without close_notify. On our OpenSSL build of curl, this is how a crashing HTTPS server showed up. |
(56) Proxy CONNECT aborted |
The proxy closed before answering CONNECT. The proxy itself refused. |
(7) CONNECT tunnel failed, response 407 |
The proxy answered with a 407. Fix the proxy credentials. |
(35) ... wrong version number |
https:// to a port that does not speak TLS. |
(1) Received HTTP/0.9 when not allowed |
Something answered with bytes that are not HTTP, such as a SOCKS server. |
(60) ... self-signed certificate in certificate chain |
A certificate your client does not trust, for example an interceptor’s. |
Behind Cloudflare: 520 and the 10xx codes
When an origin behind Cloudflare does what produced 52 on this page, the visitor never sees 52. Cloudflare’s edge is the client, and it answers the visitor with error 520, which Cloudflare defines as the origin returning an empty, unknown or unexpected response. Its listed causes include origin crashes, a firewall at the origin blocking Cloudflare’s addresses, response headers over 128 KB, and an origin that accepts HTTP/2 and then does not speak it properly.
From the visitor’s side there is nothing to fix locally. Note the Ray ID on the error page and tell the site. From the site owner’s side, the work is causes 1 to 5 against your own origin. Cloudflare’s 520 page adds a log detail: in the http_requests dataset, an OriginResponseStatus of 0 together with a CacheStatus of miss or expired means Cloudflare contacted the origin and got no HTTP response.
The 1xxx codes are a different thing. Each one is an error page that Cloudflare serves, with a Ray ID on it, so seeing a 10xx code means you got a reply. Most of the common ones mean a rule set by the site owner made a decision about the request. What Cloudflare’s documentation says about the common ones:
| Code | Cloudflare’s meaning | Visitor’s side | Site owner’s side |
|---|---|---|---|
| 1003 | Direct IP access not allowed: a client requested a Cloudflare IP address directly | Use the domain name in the URL, not the IP | Cloudflare lists no owner action; the fix is the URL |
| 1006, 1007, 1008, 1106 | Access denied because the IP address has been banned by the site | Ask the site owner; Cloudflare support cannot override it | Review the security settings that block that address |
| 1010 | The site owner banned access based on the browser’s signature | Contact the site owner | Browser Integrity Check is the setting involved |
| 1012 | Access denied over malicious activity detected from the visitor’s computer or network | Scan the machine for malware, then contact the site owner | Allow the address if the block is wrong |
| 1015 | Rate limited by rules the site owner configured | Wait before retrying; rapid retries can extend the block | Review the rate limiting thresholds and the time window |
| 1020 | A security rule with a Block action matched; returned with HTTP 403 | Send the site owner a screenshot with the Ray ID | Search Security Events for the Ray ID to find the rule |
Cause-to-fix table
| Cause | What you see | Check | Fix |
|---|---|---|---|
| Handler crashed | 52 immediately, every time | Application log at the same second | Fix the code path; let the framework answer 500 |
| Server-side timeout | 52 at a round number of seconds | -w '%{time_total}', then the server’s timeout settings |
Raise the timeout or answer 503/504 when it fires |
| Kept-alive connection reused as it closed | Intermittent; library errors while curl works | Does it fail only on reused connections? | Retry idempotent requests once; client idle timeout below the server’s |
| Plain HTTP to a TLS port | 52 or 56 reset, instantly | openssl s_client -connect host:port -brief |
Use https:// |
| HTTPS server closed after handshake | 52, or 56 “unexpected eof” on OpenSSL builds | Same as the crash and timeout rows | Same as the crash and timeout rows |
| Proxy closed instead of answering | 52 on http://, 56 “Proxy CONNECT aborted” on https:// |
Echo URL through the same proxy, with and without credentials | Correct credentials or parameters; ask the provider what it logged |
| Origin closed inside the tunnel | 52 after “CONNECT tunnel established, response 200” | Request the origin without the proxy | Fix the origin, causes 1 to 5 |
| TLS interception | 52 with an unfamiliar issuer: in -v |
Compare the issuer with a direct connection | Exclude the host from interception, or fix the origin |
| Origin behind Cloudflare fails | Visitors get 520, not 52 | OriginResponseStatus 0 with CacheStatus miss |
Origin logs; causes 1 to 5 on the origin |
How this was tested
All tests ran on one macOS 26.6.2 machine on 21 October 2026, against servers bound to 127.0.0.1. Nothing on the public internet was involved; 203.0.113.10 is a documentation address that the stand-in gateway never contacted. Clients: curl 8.23.0 (Homebrew, OpenSSL 4.0.3), curl 8.7.1 (macOS system build, SecureTransport), Python 3.9.6 with requests 2.32.3, urllib3 2.3.0 and httpx 0.27.2, Node 24.2.0, Google Chrome 155.0.8059.85 driven headless over the DevTools protocol. Servers: Python 3.15.0 http.server, Node 24.2.0 http, openssl s_server from OpenSSL 4.0.3, and Squid 6.13 configured as a plain forward proxy, an authenticating proxy, a TLS proxy port and an ssl-bump interceptor. The gateway, keep-alive and SOCKS stand-ins were short Python scripts written for this test, and are described as stand-ins wherever they appear.
Each scenario in the timing table ran 10 times in a row with curl 8.23.0, and every run of a scenario produced the same exit code. The three mix-up cases (plain HTTP to a Python TLS port, an http:// proxy URL to Squid’s TLS port, and to the SOCKS stand-in) also ran 10 times each, with the same exit code every time. The single-shot captures, such as the Squid 407 and 503 responses, are deterministic configuration behaviour and ran once or twice.
| Scenario | curl exit code | Median time (ms) |
|---|---|---|
| Node socket timeout set to 1,500 ms | 52 | 1501.4 |
| TLS origin crashed, no close_notify | 56 | 6.3 |
| Through Squid ssl-bump, origin sent close_notify only | 52 | 6.2 |
| Through Squid CONNECT, origin sent close_notify only | 52 | 3.5 |
| TLS origin sent close_notify only | 52 | 3.2 |
| http.server handler raised | 52 | 1.2 |
| Gateway dropped a plain HTTP request | 52 | 0.6 |
| Gateway dropped a CONNECT | 56 | 0.5 |
| Plain HTTP to openssl s_server | 52 | 0.3 |
These are loopback timings, so the absolute milliseconds mean little. The gap between the instant failures and the timed one is the point: on a real network the instant ones grow by one round trip, and the timed one stays pinned to its configured value.
Frequently asked questions
What does curl error 52 mean?
Is "Empty reply from server" a proxy problem?
Why does curl work but Python requests fails with RemoteDisconnected?
Is ERR_EMPTY_RESPONSE in Chrome the same thing?
What is the difference between curl 52 and curl 56?
Can a Cloudflare 1020 or 1015 cause an empty reply?
Sources
- libcurl error codes: CURLE_GOT_NOTHING (52)
- curl man page: exit code 52
- Python http.client: RemoteDisconnected
- Chromium net_error_list.h: ERR_EMPTY_RESPONSE (-324)
- Node.js http: server.timeout and server.setTimeout()
- Node.js http: server.keepAliveTimeout (default 5000 ms)
- HTTPX: HTTP transports and connection retries
- RFC 1122 section 4.2.2.13: closing a connection with unread data
- microsocks sockssrv.c: SOCKS5 greeting handling
- Cloudflare: Error 520, web server returns an unknown error
- Cloudflare: Error 1003, direct IP access not allowed
- Cloudflare: Errors 1006, 1007, 1008 or 1106, IP address banned
- Cloudflare: Error 1010, browser signature banned
- Cloudflare: Error 1012, access denied
- Cloudflare: Error 1015, rate limited
- Cloudflare: Error 1020, access denied