What error:0A000126 unexpected eof while reading means in OpenSSL 3, curl (35 and 56), Python EOF occurred in violation of protocol and wget, why it appeared after upgrading to OpenSSL 3, and safe fixes.
Home › Guides › SSL unexpected eof while reading
Last updated 18 November 2026
unexpected eof while reading means the other side closed the TCP connection without first sending the TLS close_notify alert. OpenSSL's manual says: "Some TLS implementations do not send the mandatory close_notify alert on shutdown."
Fix it on the server so it shuts TLS down properly. On the client, only ignore it if the protocol on top detects truncation itself (for example HTTP with a Content-Length), as explained below.
| Client | Server closes during the handshake | Server closes after sending data |
|---|---|---|
| curl 8.14.1 (OpenSSL 3.5.7) | curl: (35) TLS connect error: error:0A000126:SSL routines::unexpected eof while reading | curl: (56) OpenSSL SSL_read: OpenSSL/3.5.7: error:0A000126:SSL routines::unexpected eof while reading, errno 0 |
| openssl s_client (3.5.7) | error:0A000126:SSL routines::unexpected eof while reading:../ssl/record/rec_layer_s3.c:698: (exit status 1) | |
| Python 3.13.5 (ssl, urllib) | [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1029) | SSLEOFError with the same text when suppress_ragged_eofs=False; by default recv() just returns an empty bytes object |
| Python requests 2.34.2 | SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1029)')) | No error when the body has no length; ChunkedEncodingError ... IncompleteRead(6 bytes read, 94 more expected) when the body is shorter than its Content-Length |
| Node.js 24.22.1 (https) | ECONNRESET Client network socket disconnected before secure TLS connection was established | No error when the body has no length; ECONNRESET aborted when it is shorter than its Content-Length |
| wget 1.25.0 (GnuTLS) | Read error at byte 6 (The TLS connection was non-properly terminated.), then wget retries | |
The _ssl.c line number changes between Python builds. 0A000126 is the OpenSSL 3 packed error code; the reason number 294 (hex 126) is SSL_R_UNEXPECTED_EOF_WHILE_READING in OpenSSL's error table. If the server sends a TCP reset during the handshake instead of a clean close, curl says curl: (35) Recv failure: Connection reset by peer instead.
From the OpenSSL 3.0 SSL_get_error manual: "On an unexpected EOF, versions before OpenSSL 3.0 returned SSL_ERROR_SYSCALL, nothing was added to the error stack, and errno was 0. Since OpenSSL 3.0 the returned error is SSL_ERROR_SSL with a meaningful error on the error stack (SSL_R_UNEXPECTED_EOF_WHILE_READING)."
So a server that has always closed connections without close_notify worked silently with clients built on OpenSSL 1.1.1 and fails with clients built on OpenSSL 3.x. curl's own source shows the old leniency: release builds treat a bare SSL_ERROR_SYSCALL as the end of data "For compatibility with older peers". In curl's source, if OpenSSL reports SSL_ERROR_SYSCALL with nothing on the error stack and errno 0 while a read fails, the same message reads OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0.
TLS requires the alert. RFC 8446 section 6.1: "Each party MUST send a "close_notify" alert before closing its write side of the connection, unless it has already sent some error alert." and "If a transport-level close is received prior to a "close_notify", the receiver cannot know that all the data that was sent has been received." That second sentence is the reason the error exists: without the alert, a cut-off response looks the same as a complete one.
openssl s_client -connect host:443 -servername host. Add -ignore_unexpected_eof ("Do not treat lack of close_notify from a peer as an error") to confirm: if the error disappears, the only problem is the missing alert.SSL_shutdown() before closing the socket; in Python it is SSLSocket.unwrap() before close(). In our test, the same server with a proper TLS shutdown worked with every client above.OpenSSL's SSL_OP_IGNORE_UNEXPECTED_EOF option (added in OpenSSL 3.0) makes a closed connection count as if close_notify had arrived. OpenSSL's warning: "You should only enable this option if the protocol running over TLS can detect a truncation attack itself, and that the application is checking for that truncation attack."
| Where | Setting | Notes |
|---|---|---|
| C / OpenSSL 3.0+ | SSL_CTX_set_options(ctx, SSL_OP_IGNORE_UNEXPECTED_EOF) | SSL_get_error() can then return SSL_ERROR_ZERO_RETURN, as for a normal close. |
| Python 3.10+ | ctx.options |= ssl.OP_IGNORE_UNEXPECTED_EOF | Needs OpenSSL 3.0.0 or later. In our test, a mid-response close became a clean EOF. |
| openssl s_client | -ignore_unexpected_eof | Diagnosis only. |
| OpenSSL config file (3.2+) | Options = IgnoreUnexpectedEOF in the system_default section | Equivalent to SSL_OP_IGNORE_UNEXPECTED_EOF for every program that loads the config. The keyword is in ssl_conf.c from OpenSSL 3.2, not in 3.0 or 3.1. |
We tested the config-file route with OPENSSL_CONF pointing at a file with openssl_conf → ssl_conf → system_default → Options = IgnoreUnexpectedEOF: curl 8.14.1 then printed the body and exited 0 for a response without a length, but still caught the truncated one with curl: (18) end of response with 94 bytes missing (CURLE_PARTIAL_FILE). That is the kind of protocol-level check OpenSSL's warning asks for. Prefer setting it per program over a system-wide change, and remove it once the server is fixed.
The Bulk SSL Certificate Expiry Monitor on Apify handshakes with each host and port (STARTTLS automatically on 25, 587, 143, 110 and 21) and reports the negotiated TLS version and cipher with the certificate. Endpoints whose handshake fails come back as ERROR with the reason, so one run shows which servers drop the connection during the handshake ($1 per 1,000 endpoints).
Check the certificate a server issues with the SSL Certificate Checker, find the IP behind a name with DNS Lookup, see who operates it with the ASN IP Lookup and Cloud IP Lookup, and check mail hosts with the MX Record Lookup and MTA-STS Checker. Related guides: SSL wrong version number, SSL handshake failure and protocol version, self-signed certificate in certificate chain and unable to get local issuer certificate.
The peer closed the TCP connection without sending the TLS close_notify alert first. OpenSSL 3.0 and later report this as SSL_R_UNEXPECTED_EOF_WHILE_READING, shown as error:0A000126. The connection may have been cut during the handshake or after the response was sent.
OpenSSL 1.1.1 returned SSL_ERROR_SYSCALL with errno 0 and no error on the stack, which many programs treated as a normal end of data. OpenSSL 3.0 returns SSL_ERROR_SSL with SSL_R_UNEXPECTED_EOF_WHILE_READING, so the same server now produces a visible error.
Exit code 56 is CURLE_RECV_ERROR, a failure while receiving data. With this OpenSSL text it means the server closed the connection without close_notify while curl was reading the response. Exit code 35 with the same text means it happened during the TLS handshake.
Fix the server so it shuts TLS down properly. If you control the client and the protocol detects truncation itself, Python 3.10 and later with OpenSSL 3 can set ssl.OP_IGNORE_UNEXPECTED_EOF on the SSLContext. If it fails during connect, the server or a middlebox is dropping the connection and the option will not help.
Only if the protocol on top of TLS can detect a truncated message and your application checks for it, which is OpenSSL's own warning. HTTP responses with a Content-Length or chunked encoding can be checked; a response that simply ends at connection close cannot.
Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.