How to Set Up Proxies in Node.js Axios
Route Node.js Axios traffic through an authenticated proxy in a few lines. Copy the code below and swap in your credentials.
Quick answer
Set the proxy in the format http://user:pass@host:port (via proxy-agent) and send your Node.js Axios request through it. Full code below.
Node.js Axios proxy example
const axios = require("axios");
const { HttpsProxyAgent } = require("https-proxy-agent");
const agent = new HttpsProxyAgent("http://user:pass@host:port");
axios.get("https://httpbin.org/ip", {
httpAgent: agent,
httpsProxyAgent: agent,
}).then((r) => console.log(r.data));Axios ships a built-in proxy option, but it mishandles HTTPS-over-HTTP tunneling, so the reliable pattern is to attach an https-proxy-agent (or socks-proxy-agent) and set proxy: false to disable the native path. The agent embeds credentials in the URL, so authenticated residential and datacenter endpoints just work. For rotation, construct a new agent per request or per worker pointed at a rotating gateway.
Rotating proxies
Node.js Axios works cleanly with rotating backconnect endpoints — point it at a single gateway host and the provider rotates the exit IP for you.
Best proxies to use with Node.js Axios
Cheapest-Proxies.com EDITOR'S CHOICE
4.9Best overall value across every proxy type and use case · flexible pay-as-you-go plans
Visit Cheapest-Proxies.comBright Data
4.6Enterprise-grade proxy and web data platform · from ~$8-9/GB (residential, volume-dependent)
Read Bright Data reviewOxylabs
4.6Premium enterprise proxies and scraper APIs · from ~$8/GB (residential, volume-dependent)
Read Oxylabs reviewSmartproxy
4.5User-friendly proxies with excellent price-to-performance · from ~$3.50-7/GB (residential)
Read Smartproxy reviewOur #1 pick is a sponsored partner. Remaining providers are ranked editorially by rating and value.
Frequently Asked Questions
Does Node.js Axios support authenticated proxies?
Yes. Provide the username and password (as a URL or separate fields) and Node.js Axios handles the auth handshake.
Can Node.js Axios rotate proxies automatically?
Yes — point it at a rotating backconnect endpoint and the provider rotates IPs for you.
How do I add a proxy in Node.js Axios?
Supply the proxy as http://user:pass@host:port (via proxy-agent) and pass it to Node.js Axios as shown in the code above.
What proxies work best with Node.js Axios?
Residential or rotating proxies from a reliable provider give the best success rate for Node.js projects.
Related Guides
Best proxies for Node.js Axios
We compared 40+ providers on price, coverage, and reliability — this one offered the best overall value.
Visit Cheapest-Proxies.com