Before you start
Nefo offers residential proxies across 227 countries over HTTP, HTTPS, and SOCKS5 with username/password auth. Generate credentials for free in the dashboard proxy generator; only routed traffic consumes your prepaid bandwidth (from 5 GB for $4.50, non-expiring on flexible plans).
Axios needs an explicit agent for reliable HTTPS-over-proxy behavior, so use https-proxy-agent rather than the built-in proxy option.
- Node.js 18+ with axios installed
- https-proxy-agent (or socks-proxy-agent for SOCKS5) installed
- A Nefo account with prepaid bandwidth
- A username/password from /dashboard/generator
- Your target country token
Axios proxy agent example
Create an agent and attach it to the request:
For SOCKS5, use socks-proxy-agent with socks5://USERNAME-country-us:[email protected]:11000. Change the country token to target any of 227 countries.
const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');
const agent = new HttpsProxyAgent(
'http://USERNAME-country-us:[email protected]:9000'
);
(async () => {
const res = await axios.get('https://api.ipify.org', {
httpAgent: agent,
httpsAgent: agent,
});
console.log(res.data);
})();Axios rotating vs sticky proxy sessions
Rotating sessions assign a new residential IP per request: HTTP port 9000 or SOCKS5 port 11000. Best for spreading many requests across exits.
Sticky sessions hold one IP from 1 minute up to 24 hours: HTTP port 10000 or SOCKS5 port 12000. Reuse one agent built with a token like USERNAME-country-us-session-api3-lifetime-60 so all requests on that agent share the same IP.
Geo-targeting in the Axios proxy username
Targeting is expressed entirely in the username: country across 227 countries, US state and city, or ASN/ISP within a country. Only the username in the agent URL changes between regions.
Collect data lawfully, honor each site's terms of service, and respect applicable law and sensible request pacing.
Frequently asked questions
Axios's built-in proxy option is unreliable for HTTPS targets. An https-proxy-agent tunnels correctly, so set it as both httpAgent and httpsAgent and leave the built-in proxy option unset.
Build one agent with port 10000 and a session token such as USERNAME-country-us-session-abc-lifetime-60, then reuse that agent for every request so the IP persists for up to 24 hours.
Install socks-proxy-agent and create the agent from socks5://USERNAME-country-us:[email protected]:11000, or port 12000 for sticky. Pass it as httpAgent and httpsAgent the same way.
Check that you are using an agent rather than the proxy option, that the username and password match the proxy generator exactly, and that the port is one of 9000, 10000, 11000 or 12000. The docs list the connection details.
Yes. Set tokens in the username, such as USERNAME-country-ca, or US state and city tokens. Only the agent URL changes between regions.
No. Generating credentials is free, and only the traffic routed through the proxy uses your prepaid bandwidth.