JS
Languages & HTTP Clients

Node.js (Axios) proxy integration

Node's Axios doesn't tunnel HTTPS-over-HTTP proxies reliably through its built-in proxy option, so the standard approach is an https-proxy-agent. Point the agent at your Aethyn endpoint and pass it as both httpAgent and httpsAgent.

Setup steps

  1. 1Install dependencies: npm install axios https-proxy-agent.
  2. 2Create an HttpsProxyAgent with your Aethyn credentials.
  3. 3Pass the agent to Axios as httpAgent and httpsAgent.
  4. 4Disable Axios's own proxy handling with proxy: false.

Code

Axios with https-proxy-agent
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent(
  "http://aethyn-XXXXX-country-us:PASSWORD@proxy.aethyn.io:2099"
);

const { data } = await axios.get("https://httpbin.org/ip", {
  httpAgent: agent,
  httpsAgent: agent,
  proxy: false, // let the agent handle it
});

console.log(data);
Native fetch (Node 18+) with undici
import { ProxyAgent, fetch } from "undici";

const dispatcher = new ProxyAgent(
  "http://aethyn-XXXXX:PASSWORD@proxy.aethyn.io:2099"
);

const res = await fetch("https://httpbin.org/ip", { dispatcher });
console.log(await res.json());

Replace aethyn-XXXXX and PASSWORD with your dashboard credentials. See the full targeting reference and protocol/port list. Or use the official proxy-builder-sdk to build targeting strings without hand-assembling usernames.

Tips

  • Set proxy: false on the Axios call so it doesn't fight the agent.
  • Reuse one agent instance across requests to pool connections.
  • For browser-style scraping, pair this with Puppeteer or Playwright instead.

Node.js (Axios) proxy FAQ

Why doesn't Axios's built-in proxy option work?
Axios's proxy option struggles with HTTPS targets through an HTTP proxy. Using https-proxy-agent (or undici's ProxyAgent for fetch) is the reliable pattern for residential proxies.

Ready to wire up Node.js (Axios)?

Get your credentials and route your first Node.js (Axios) request through residential IPs in minutes.

Docs, solutions & blog

Related integrations

All integrations