Registry / http-networking / proxy-http-agent

proxy-http-agent

JSON →
library1.0.1jsnpmunverified

ProxyHttpAgent (v1.0.1) is a factory for creating HTTP proxy agents supporting https→(http, https) and http→(http, https) tunneling, built on top of the node-tunnel module. It allows you to easily use proxies with http/https modules or node-fetch, with flexible proxy configuration via URL or object. Published as TypeScript-first with built-in type definitions, it exports `getProxyHttpAgent` along with `HttpsAgent` and `HttpAgent` types. Released in 2025, it is currently at stable v1. It differentiates by offering a simple API for creating agents that support both secure and insecure proxy connections with minimal boilerplate.

npm install proxy-http-agent
INSTALL
IMPORT
SIG · PROXY-HTTP-AGENT
P
proxy-http-agent
http-networkingjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getProxyHttpAgent
import { getProxyHttpAgent } from 'proxy-http-agent'
const getProxyHttpAgent = require('proxy-http-agent')
ESM import is preferred; the package provides TypeScript types.
HttpsAgent
import { HttpsAgent } from 'proxy-http-agent'
TypeScript type for the returned https.Agent instance.
HttpAgent
import { HttpAgent } from 'proxy-http-agent'
TypeScript type for the returned http.Agent instance.

Creating a proxy agent with proxy URL from environment and using it with https.get.

import { getProxyHttpAgent } from 'proxy-http-agent'; import https from 'https'; const proxyUrl = process.env.HTTP_PROXY ?? 'http://localhost:3128'; const agent = getProxyHttpAgent({ proxy: proxyUrl, rejectUnauthorized: false }); const options = { hostname: 'example.com', port: 443, path: '/', agent }; https.get(options, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => console.log(data)); }).on('error', (err) => console.error(err));
Debug
Known issues
gotchaOptions object may override agent settings; ensure `agent` is set correctly.
fix
Use `opts.agent = agent` after parsing URL, and delete any existing `port` to avoid conflicts.
affects: >=1.0.0
deprecatedThe npm package name 'proxy-http-agent' may be confused with other similarly named packages. Always verify the correct package.
fix
Double-check package name in package.json.
affects: >=1.0.0
gotchaWhen using string proxy URL, ensure protocol is specified (http:// or https://).
fix
Always include the protocol in the proxy URL, e.g., 'http://proxy.example.com:8080'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: getaddrinfo ENOTFOUND proxy.example.com
Proxy hostname not resolvable or network issue.
fix
Check proxy URL and network connectivity.
TypeError: agent is not a function
Incorrect import: importing `getProxyHttpAgent` as a function when not imported correctly.
fix
Use `import { getProxyHttpAgent } from 'proxy-http-agent'` instead of `import getProxyHttpAgent from 'proxy-http-agent'`.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
tunnelrequiredCore dependency for creating tunnel agents
Agent activity
7 hits · last 30 days
node
6
Resources
proxy-http-agent — npm install proxy-http-agent · libregistry