unexpected eof SSL / TLS Origin: Network OSI layer 6 · Presentation Last updated 18 Nov 2026

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.

Exact message you may see 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
Seen on: SSL OpenSSL Python

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

  1. Verify the response is complete
  2. Raise idle/read timeouts
  3. Use SSL_OP_IGNORE_UNEXPECTED_EOF only where lengths are known

Detailed fix by platform

Python

  1. python
    import ssl
    ctx = ssl.create_default_context()
    ctx.options |= getattr(ssl, "OP_IGNORE_UNEXPECTED_EOF", 0)

How to diagnose

  1. Response — Complete?
  2. Timeout — Cut it?
  3. 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:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

ACM region — CloudFront can't use my ACM certificate: it must be requested in us-east-1 (N. Virginia) (SSL / TLS)ACM regionbad record mac — SSL error: bad record mac (decryption failed or corrupted TLS record) (SSL / TLS)bad record macDjango — Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port) (Email / SMTP)DjangoEOF occurred in violation of protocol — Python: ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2396) (SSL / TLS)EOF occurred in viola…legacy provider — OpenSSL 3: Error outputting keys and certificates ... unsupported (PKCS#12 uses legacy RC2/3DES) (SSL / TLS)legacy providerpremature close — Response truncated: connection closed before the full body arrived (HTTP)premature closerenegotiation — unsafe legacy renegotiation disabled (OpenSSL 3) when connecting to an old server (SSL / TLS)renegotiationTimeout during connect (likely firewall problem) — Let's Encrypt: Fetching http://example.com/.well-known/acme-challenge/token: Timeout during connect (likely firewall problem) (SSL / TLS)Timeout during connec…unexpecte…

Explore the map of this error Full error map →

🧠 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.