Integrations · Automation & scraping
Use HProxy with Axios & Node.js.
Route Axios or node-fetch through an HProxy proxy with a proxy agent.
Axios is the most popular HTTP client for Node and the browser; in Node it needs a proxy agent to route through an upstream proxy.
Server-side Node requests come from a datacenter by default, the first thing a reputation check flags. A residential agent puts an ordinary-looking IP in front of every call.
Setting up HProxy in Axios & Node.js
- 1.Install https-proxy-agent (npm i https-proxy-agent).
- 2.Build an agent from your proxy URL, login included.
- 3.Pass the agent to Axios (httpsAgent) or to node-fetch (agent).
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent("http://user-country-us:pass@res.hproxy.com:8080");
const { data } = await axios.get("https://ipinfo.io/json", { httpsAgent: agent });
console.log(data);Frequently asked questions
Why does the axios proxy option not work for HTTPS?
Because axios handles the proxy config itself rather than letting Node's agent do it, and that path has long been unreliable for HTTPS targets, frequently ignoring the setting or failing the tunnel. The dependable approach is an explicit proxy agent passed as httpsAgent, which is what the example above uses.
Do I need to set both httpAgent and httpsAgent?
Set the one matching the scheme you actually call, and setting both is the safer default when a job hits a mixture. A common bug is configuring only httpAgent, seeing HTTP requests routed correctly, and never noticing that every HTTPS request went direct.
How do I use one proxy for every axios call?
Create an instance with axios.create and attach the agent there, then use that instance everywhere instead of the global axios. It removes the class of bug where one call was written against the bare import and silently bypasses the proxy.
Why does my Node scraper get blocked when the browser works?
Usually the TLS fingerprint. Node's HTTP stack negotiates encryption differently from Chrome, and detection systems read that handshake before your request is decrypted, so copying the headers and user agent changes nothing underneath. It is the most common cause of a block that survives changing proxies.
The host, port and login shown here are the format; your exact values are on your dashboard, ready to copy.