Node.js request fails with EPROTO and WRONG_VERSION_NUMBER
Error: write EPROTO ... error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBERShort 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.
Fix it fast
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 202Match what you see, then jump to its fix
- 1
A 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
It 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
- 1
What does the error look like?
Error: write EPROTO ... error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBERssl3_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/healthConfirmed by github.com
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 302Fix
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 proxy3Verify
The openssl s_client check now prints a certificate chain.
openssl s_client -connect example.com:443 </dev/null | head -n 15Confirmed by github.com
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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack 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 fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix