How to set up a proxy in Node.js (Axios & Native Fetch)

Updated:

Axios's built-in proxy: { host, port } option fails on https:// targets because it does not issue an HTTP CONNECT tunnel. To route Node.js and TypeScript requests cleanly through VinaProxy authenticated HTTP(S) proxies, pass an HttpsProxyAgent (https-proxy-agent) to Axios or an undici.ProxyAgent dispatcher to native Node fetch().

Node.js (Axios / Undici) · HTTP Proxy Format
new HttpsProxyAgent('http://user:pass@ip:port')
Private IPv4 (datacenter)
🇺🇸 United States
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy United States
Private IPv4 (datacenter)
🇸🇬 Singapore
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy Singapore

Axios vs. Native Node.js fetch() proxy configuration

Both libraries accept standard http://user:pass@ip:port URLs from your VinaProxy dashboard:

HTTP ClientPackageRecommended Code Snippet
Axiosnpm i https-proxy-agentaxios.get(url, { httpsAgent: new HttpsProxyAgent('http://user:pass@ip:port'), proxy: false })
Native fetch (Node 18+)npm i undicifetch(url, { dispatcher: new ProxyAgent('http://user:pass@ip:port') })
Gotnpm i hpagentgot(url, { agent: { https: new HttpsProxyAgent({ proxy: 'http://user:pass@ip:port' }) } })

Connection pooling & timeout best practices in Node.js

  • Always set proxy: false alongside httpsAgent in Axios so Axios ignores conflicting system HTTP_PROXY environment variables
  • Instantiate HttpsProxyAgent or ProxyAgent once per proxy IP outside your loop to reuse persistent keep-alive sockets
  • Export your VinaProxy proxy list directly as a JSON array using our Proxy Format Converter

Step by step

  1. 1

    Install https-proxy-agent (or undici)

    Run npm install axios https-proxy-agent in your Node.js project.

  2. 2

    Create the HttpsProxyAgent instance

    Initialize const agent = new HttpsProxyAgent('http://user:pass@ip:port'); using your VinaProxy credentials.

  3. 3

    Pass httpsAgent and proxy: false to Axios

    Call const res = await axios.get('https://vinaproxy.com/api/my-ip', { httpsAgent: agent, proxy: false, timeout: 10000 });.

  4. 4

    Verify the exit IP

    Log res.data to confirm the response came through your dedicated proxy IP.

Frequently asked questions

Why does Axios's default `proxy: { host, port, auth }` fail on HTTPS URLs?

Axios's built-in proxy config sends a plain HTTP request instead of opening an HTTP CONNECT TLS tunnel. Using httpsAgent: new HttpsProxyAgent('http://user:pass@ip:port') with proxy: false fixes this.

How do I use a proxy with native `fetch()` in Node.js 18/20/22?

Import ProxyAgent from undici and pass { dispatcher: new ProxyAgent('http://user:pass@ip:port') } in the fetch() options object.

Can I convert my proxy list to JSON for Node.js?

Yes—paste your ip:port:user:pass lines into our free Proxy Format Converter and select JSON output.

Power your Node.js backends & scrapers with static IPs

Instant unmetered Dedicated IPv4 and Static ISP proxies across 7 countries.

Buy Node.js Proxies

Related articles

Proxies by platform
Proxies for Web Scraping: unmetered dedicated IPv4 & ISP pools for 24/7 crawlers
High-speed HTTP(S) dedicated IPv4 and Static ISP proxies for Python, Playwright, Selenium, and Scrapy with unlimited monthly bandwidth.
Proxy setup
How to set up an authenticated proxy in Puppeteer (Node.js)
Configure authenticated HTTP(S) proxies in Node.js Puppeteer using the --proxy-server launch flag and await page.authenticate().
Proxy setup
How to set up a proxy in Playwright (Browser & Per-Context Auth)
Configure authenticated HTTP(S) proxies in Playwright for Node.js and Python. Run multiple isolated static IPs across BrowserContexts.
Free tools
Bulk Proxy Format Converter (100% Client-Side)
100% client-side bulk proxy list formatter. Convert between ip:port:user:pass, user:pass@ip:port, http:// URLs, SOCKS5 URIs, JSON arrays, and FoxyProxy exports.
Proxies by platform
Proxies for SEO & SERP Tracking: accurate keyword rankings across 7 countries
Track localized keyword rankings, audit geo-redirects, and run Screaming Frog crawls with unmetered dedicated IPv4 and Static ISP proxies.
Proxies by platform
Proxies for Discord: isolate accounts and tokens on dedicated static IPs
Keep multiple Discord accounts and tokens safe from phone-verification locks and Cloudflare blocks. Dedicated US, Singapore, and Vietnam static proxies.
IPV4 · united states
US Private IPv4 Proxies: Fast, Dedicated American Datacenter IPs
Dedicated US private IPv4 proxies for scraping, rank tracking, ad checks and Amazon research. Static IP, one user per IP, unlimited bandwidth, fast activation.
IPV4 · singapore
Singapore Private IPv4 Proxies: Fast, Dedicated SG IPs for Regional Selling and Ads
Dedicated Singapore private IPv4 proxies for Lazada and Shopee SG stores, regional ad accounts, ad verification and low-latency automation. Unlimited data.