OpenSSL 3: error:0A000126:SSL routines::unexpected eof while reading
The peer closed the TLS connection without sending a close_notify alert, which OpenSSL 3 treats as an error.
unexpected eof while readingerror:0A000126:SSL routines::unexpected eof while readingSSL: UNEXPECTED_EOF_WHILE_READINGssl.SSLEOFError: EOF occurred in violation of protocol UNEXPECTED_EOFcurl: (56) OpenSSL SSL_read: error:0A000126 Meaning
Many servers/proxies simply close the socket. It can mean a truncated response, a crash or a timeout on the server side. If your protocol knows the message length, you can ignore it (SSL_OP_IGNORE_UNEXPECTED_EOF), but first check for truncated data and idle timeouts.
Common causes
- Server/proxy closed the connection without close_notify
- Idle timeout cut the connection
- Response truncated by a crash
- OpenSSL 3 stricter than 1.1.1
- Backend closing early
⚡ Quick fix
- Verify the response is complete
- Raise idle/read timeouts
- Use
SSL_OP_IGNORE_UNEXPECTED_EOFonly where lengths are known
Detailed fix by platform
Python
- python
import ssl ctx = ssl.create_default_context() ctx.options |= getattr(ssl, "OP_IGNORE_UNEXPECTED_EOF", 0)
How to diagnose
- Response — Complete?
- Timeout — Cut it?
- Backend — Crashed?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- ACM region CloudFront can't use my ACM certificate: it must be requested in us-east-1 (N. Virginia)
- bad record mac SSL error: bad record mac (decryption failed or corrupted TLS record)
- Django Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port)
Most viewed in SSL / TLS
- HTTPSConnectionPool: Max retries exceeded (SSLError) Python requests: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] ...')))
- DST Root CA X3 expired (old clients fail) Old clients: certificate has expired — Let's Encrypt chain uses expired DST Root CA X3 (OpenSSL 1.0.x, Android < 7.1.1)
- Keystore was tampered with, or password was incorrect Java keytool: java.io.IOException: Keystore was tampered with, or password was incorrect
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026