# Node.js: write EPROTO ... SSL routines:ssl3_get_record:wrong version number (https:// to an HTTP port, or http agent for https)

**Code:** `wrong version number` · **Category:** SSL / TLS · **Seen on:** Node.js, SSL

The client attempted TLS against a server (or port) that doesn't speak TLS, or used the wrong HTTP agent.

## Meaning

Check the URL scheme/port, use `https.request`/`https.Agent` for https URLs, and verify any proxy settings (an HTTP proxy URL with an `https` agent is a classic mistake). Test with `curl -v`.

## Common causes

- `https://` to a plain HTTP port
- `http.Agent` used for an https URL
- Proxy URL scheme mismatch
- Server redirecting to plain HTTP
- Local dev server without TLS

## Quick fix

1. Match scheme and port
2. Use the correct agent (`https-proxy-agent` for proxies)
3. Verify with `curl -v` and `openssl s_client`

## Detailed fix by platform

### Node.js

1. 

```javascript
const agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
await fetch(url, { agent });
```


## How to diagnose

1. **Scheme** — Matches port?
2. **Agent** — https?
3. **Proxy** — Configured right?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/node-err-ssl-wrong-version-number)
