Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Node.js request fails with EPROTO and WRONG_VERSION_NUMBER

ErrorError: write EPROTO ... error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER

Short answer

WRONG_VERSION_NUMBER means the TLS client received a record whose version does not match what it expects. In Node.js a typical way to get it is an https request sent to a port that speaks plain HTTP, or a plain-text reply from a proxy or portal. Check the raw reply with openssl s_client, then fix the scheme, port or proxy.

  • Applies to Node.js 22, Node.js 24, OpenSSL 3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at what the server answers on that exact host and port. If you see readable HTTP text instead of a certificate, the endpoint is not speaking TLS.

    openssl s_client -connect example.com:443 -msg </dev/null | head -n 20
  2. 2Match what you see, then jump to its fix

    1. 1A local or internal service on a port such as 3000, 8080 or 5000 fails, while http:// to the same port worksThe URL says https but the port serves plain HTTPFix
    2. 2It works from another network and fails on hotel, office or guest Wi-Fi, or behind a corporate proxyA proxy, captive portal or load balancer answers in plain textFix

What does the error look like?

  • Error: write EPROTO ... error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER
  • ssl3_get_record:wrong version number

Cause 1 of 2

The URL says https but the port serves plain HTTP

1Check

In the OpenSSL source the record header is validated first, and a record version that differs from the expected one raises this error. A service that answers in plain text produces such bytes. Test the same port without TLS.

curl -v http://localhost:3000/
curl -v https://localhost:3000/

2Fix

Use http:// for that service, or turn on TLS on the server. Do not fix it by disabling certificate checks; that is not the problem.

// client
const res = await fetch('http://localhost:3000/health');

3Verify

The request succeeds.

curl -i http://localhost:3000/health

Confirmed by github.com

Did this fix it?

Cause 2 of 2

A proxy, captive portal or load balancer answers in plain text

1Check

A device in the path that answers in plain text instead of TLS makes the client read those bytes as a record header, and the version check fails. Fetch the URL and read what comes back.

curl -v https://example.com 2>&1 | head -n 30

2Fix

Sign in to the portal, or switch to a network that allows the traffic. For a proxy, check the proxy address and scheme your environment gives Node.js (HTTPS_PROXY and the proxy settings of your HTTP client), and use the one that supports CONNECT.

env | grep -i proxy

3Verify

The openssl s_client check now prints a certificate chain.

openssl s_client -connect example.com:443 </dev/null | head -n 15

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Keep the scheme and port together in one config value (a full URL), not two separate settings.
  • Document which internal services speak TLS and which do not.
  • Log the full URL a failed request used, without secrets.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.