Home/Docs/Axios
Integration guide 150+ countries 99.9% uptime

How to Use ProxyOmega Proxies with Axios

Axios is the most popular HTTP client for Node.js. Its built-in proxy option works fine for HTTP targets, but HTTPS targets need an explicit https-proxy-agent — that is the single biggest gotcha and the source of most "axios proxy not working" support questions.

Quick start

Use the Premium Unlimited endpoint below — it accepts the username-modifier syntax used throughout this guide. Other plans use the same code shape with a different host and port (see the endpoint table at the bottom).

Quick start (HTTPS-safe)javascript
// npm install axios https-proxy-agent
const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');

const proxy = 'http://<USERNAME>:<PASSWORD>@premium.proxyomega.com:8000';
const agent = new HttpsProxyAgent(proxy);

(async () => {
  const res = await axios.get('https://api.ipify.org?format=json', {
    httpAgent: agent,
    httpsAgent: agent,
    proxy: false  // critical — let the agent handle CONNECT
  });
  console.log(res.data);
})();

Rotation: sticky session vs rotating

Append -session-<id>-ttl-<seconds> to your username to hold the same exit IP. Drop the suffix entirely for a fresh IP on every request.

Sticky session vs rotatingjavascript
const { HttpsProxyAgent } = require('https-proxy-agent');
const base = 'premium.proxyomega.com:8000';

// Rotating — bare username
const rot = new HttpsProxyAgent(`http://<USERNAME>:<PASSWORD>@${base}`);

// Sticky — keep IP for 300s
const sid = Math.random().toString(36).slice(2, 10);
const stick = new HttpsProxyAgent(
  `http://<USERNAME>-session-${sid}-ttl-300:<PASSWORD>@${base}`
);

await axios.get('https://api.ipify.org', { httpsAgent: stick, proxy: false });

Country targeting

Add -country-XX (ISO 3166 alpha-2) to your username. State and city modifiers are supported on Premium Unlimited, Platinum and Mobile.

Country targetingjavascript
const { HttpsProxyAgent } = require('https-proxy-agent');

const de  = new HttpsProxyAgent('http://<USERNAME>-country-de:<PASSWORD>@premium.proxyomega.com:8000');
const us  = new HttpsProxyAgent('http://<USERNAME>-country-us-state-NY:<PASSWORD>@premium.proxyomega.com:8000');

const r = await axios.get('https://api.ipify.org',
                          { httpsAgent: de, proxy: false });
console.log(r.data);

Authentication: username/password vs IP whitelist

Two ways to authenticate. Username/password is set on every request and is what every example in this guide uses. IP whitelist is configured in the ProxyOmega dashboard — once your runner IP is listed, drop the credentials from the proxy URL and the connection is authorised by source IP.

For HTTPS targets, always pass proxy: false and let HttpsProxyAgent handle the CONNECT tunnel. Setting axios.defaults.proxy alone leaks DNS to your origin and silently bypasses the proxy on HTTPS.

Common errors and fixes

HTTP 407 Proxy Authentication Required

Wrong username or password, or the credentials contain a special character that was not URL-encoded. Re-copy from the dashboard.

Connection refused / connection reset

Either the runner IP is not on your whitelist (if you use IP auth) or your network blocks outbound on the proxy port. Test with curl first.

Read timeout / no response

Residential exits sometimes have tail latency. Raise client timeout to 30–60 s and enable retry. If timeouts persist across many sessions, the target is rate-limiting your country — switch country.

Always the same IP returned

You have a -session- suffix in your username, or HTTP keep-alive is reusing the connection. Drop the session suffix and disable keep-alive on the client to force new exits.

Recommended plan

Premium Unlimited Residential
Username-modifier syntax composes cleanly with how Axios reuses agents across requests.
View plan

All endpoints

PlanHostPortNotes
Budget Unlimitedresidential.proxyomega.com10000–10099Per-port country / rotation set in the dashboard. No username suffixes.
Premium Unlimitedpremium.proxyomega.com8000Username modifiers: -country-XX, -session-{id}-ttl-{seconds}.
Platinumplatinum.proxyomega.com20228ASN / state / city targeting via username modifiers.
Mobilemobile.proxyomega.com20229Real 4G/5G carrier IPs. Same username modifier syntax.
IPv6ipv6.proxyomega.com9000IPv6 exits, supports UDP_ASSOCIATE.

FAQ

Why does axios ignore the proxy on HTTPS URLs?

Axios’s built-in proxy option only handles HTTP. For HTTPS you must use https-proxy-agent with proxy: false. This is by design — see the axios GitHub issue tracker.

Can I reuse the same agent across many requests?

Yes and you should — agents pool the underlying TCP/TLS connections to the proxy, which saves the CONNECT handshake on every call.

How do I rotate IP without recreating the agent?

Recreate the agent — the username determines exit IP behaviour, and it is read at CONNECT time. Cache one agent per sticky-id you need.

Does fetch / undici support the same proxy URL?

Yes — set the global dispatcher to a new undici.ProxyAgent with the same URL. The ProxyOmega username syntax is identical.

Related guides

Ready to use ProxyOmega with Axios?
Sign up in under a minute. Pay-as-you-go and unlimited plans available.