Popular HTTP client for Node.js and browsers. Route axios requests through KnoxProxy with a simple proxy agent configuration.
Install axios and the proxy agent.
npm install axios https-proxy-agentCreate an HTTPS proxy agent.
const { HttpsProxyAgent } = require('https-proxy-agent');
const agent = new HttpsProxyAgent('http://USER:PASS@gw.knoxproxy.com:7000');Pass the agent to axios.
const axios = require('axios');
const { data } = await axios.get('https://httpbin.org/ip', { httpsAgent: agent });
console.log(data);Country in username.
const agent = new HttpsProxyAgent('http://USER-country-jp:PASS@gw.knoxproxy.com:7000');Catch proxy errors.
try {
const { data } = await axios.get(url, { httpsAgent: agent, timeout: 30000 });
} catch (err) {
console.error('Proxy error:', err.message);
}Verify exit IP.
const { data } = await axios.get('https://httpbin.org/ip', { httpsAgent: agent });
console.log('Exit IP:', data.origin);/**
* KnoxProxy + Axios -- complete working example.
*/
const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');
const PROXY_URL = 'http://USER:PASS@gw.knoxproxy.com:7000';
const agent = new HttpsProxyAgent(PROXY_URL);
async function main() {
// Basic request
const { data } = await axios.get('https://httpbin.org/ip', {
httpsAgent: agent,
timeout: 30000,
});
console.log('Exit IP:', data.origin);
// Country-targeted
const deAgent = new HttpsProxyAgent(
'http://USER-country-de:PASS@gw.knoxproxy.com:7000'
);
const { data: deData } = await axios.get('https://httpbin.org/ip', {
httpsAgent: deAgent,
timeout: 30000,
});
console.log('DE IP:', deData.origin);
}
main().catch(console.error);Each request gets a new IP through the gateway. For sticky sessions, use -session-{id} in the proxy username.
| Problem | Fix |
|---|---|
| ECONNREFUSED | Verify gateway host and port. Check firewall rules. |
| Request failed with status code 407 | Check username and password in your KnoxProxy dashboard. |
| ETIMEDOUT | Increase timeout. Check if target is accessible. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Yes, for HTTPS targets. Axios has no built-in support for tunneling HTTPS requests through an HTTP proxy like KnoxProxy, so the https-proxy-agent package is required to handle the CONNECT tunnel correctly. Install it with npm install https-proxy-agent, pass the agent as httpsAgent in your request config, and HTTPS calls route through KnoxProxy normally.
Yes, axios interceptors work normally alongside KnoxProxy. Set the httpsAgent option on your axios instance once, and any request or response interceptors you register still run exactly as they would without a proxy, since the agent only changes how the connection is routed, not how axios processes the request and response objects.
Each request that goes through the KnoxProxy gateway rotates to a fresh IP automatically, so you do not need to do anything extra for basic rotation with Axios. For sticky sessions, where you want the same IP across several requests, create a new HttpsProxyAgent with -session-{id} appended to the username and reuse that agent for the whole session.
Yes, Axios supports SOCKS5 with an extra package. Install socks-proxy-agent with npm install socks-proxy-agent, then create an agent with SocksProxyAgent("socks5://USER:PASS@gw.knoxproxy.com:7001") and pass it as both httpAgent and httpsAgent in your request config. Port 7001 is the dedicated KnoxProxy SOCKS5 gateway, separate from the HTTP proxy on port 7000.
Rotating residential proxies -- 3 minutes setup, instant activation, 14-day money-back guarantee.