# https-proxy-agent

> An HTTP(s) proxy `http.Agent` implementation for HTTPS

Latest version **9.1.0** (published 2026-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install https-proxy-agent
pnpm add https-proxy-agent
yarn add https-proxy-agent
bun add https-proxy-agent
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 9.1.0 |
| Published | 2026-06-08 |
| First published | 2013-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >= 20 |
| Dependencies | 3 |
| Unpacked size | 32.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1163 |
| Author | Nathan Rajlich |
| Maintainers | tootallnate |
| Keywords | https, proxy, endpoint, agent |

## Links

- npm: https://www.npmjs.com/package/https-proxy-agent
- Repository: https://github.com/TooTallNate/proxy-agents
- Homepage: https://github.com/TooTallNate/proxy-agents#readme
- Issues: https://github.com/TooTallNate/proxy-agents/issues
- npm.io page: https://npm.io/package/https-proxy-agent

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [agent-base](https://npm.io/package/agent-base.md) 9.0.0
- [proxy-agent-negotiate](https://npm.io/package/proxy-agent-negotiate.md) 1.1.0

## Recent versions

- 9.1.0 (latest) — 2026-06-08
- 9.0.0 — 2026-04-01
- 8.0.0 — 2026-03-11
- 7.0.6 — 2024-12-07
- 7.0.5 — 2024-06-28
- 7.0.4 — 2024-02-15
- 7.0.3 — 2024-02-12
- 7.0.2 — 2023-09-04
- 7.0.1 — 2023-07-10
- 7.0.0 — 2023-05-25
- 6.2.1 — 2023-05-24
- 6.2.0 — 2023-05-18
- 6.1.0 — 2023-05-05
- 6.0.0 — 2023-05-04
- 5.0.1 — 2022-04-14
- … 24 more at https://npm.io/package/https-proxy-agent/versions

## README

https-proxy-agent
================
### An HTTP(s) proxy `http.Agent` implementation for HTTPS

This module provides an `http.Agent` implementation that connects to a specified
HTTP or HTTPS proxy server, and can be used with the built-in `https` module.

Specifically, this `Agent` implementation connects to an intermediary "proxy"
server and issues the [CONNECT HTTP method][CONNECT], which tells the proxy to
open a direct TCP connection to the destination server.

Since this agent implements the CONNECT HTTP method, it also works with other
protocols that use this method when connecting over proxies (i.e. WebSockets).
See the "Examples" section below for more.

Examples
--------

#### `https` module example

```ts
import * as https from 'https';
import { HttpsProxyAgent } from 'https-proxy-agent';

const agent = new HttpsProxyAgent('http://168.63.76.32:3128');

https.get('https://example.com', { agent }, (res) => {
  console.log('"response" event!', res.headers);
  res.pipe(process.stdout);
});
```

#### `ws` WebSocket connection example

```ts
import WebSocket from 'ws';
import { HttpsProxyAgent } from 'https-proxy-agent';

const agent = new HttpsProxyAgent('http://168.63.76.32:3128');
const socket = new WebSocket('ws://echo.websocket.org', { agent });

socket.on('open', function () {
  console.log('"open" event!');
  socket.send('hello world');
});

socket.on('message', function (data, flags) {
  console.log('"message" event! %j %j', data, flags);
  socket.close();
});
```

API
---

### new HttpsProxyAgent(proxy: string | URL, options?: HttpsProxyAgentOptions)

The `HttpsProxyAgent` class implements an `http.Agent` subclass that connects
to the specified "HTTP(s) proxy server" in order to proxy HTTPS and/or WebSocket
requests. This is achieved by using the [HTTP `CONNECT` method][CONNECT].

The `proxy` argument is the URL for the proxy server.

The `options` argument accepts the usual `http.Agent` constructor options, and
some additional properties:

 * `headers` - Object containing additional headers to send to the proxy server
   in the `CONNECT` request.

[CONNECT]: http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_Tunneling

---
_Source: https://npm.io/package/https-proxy-agent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
