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 does not natively support HTTPS-over-HTTP proxies. The https-proxy-agent package handles the CONNECT tunnel.
Yes. Set the httpsAgent on the axios instance and interceptors work normally for request/response transformation.
Each request through the gateway gets a fresh IP automatically. Create a new HttpsProxyAgent with -session-{id} for sticky sessions.
Yes, with socks-proxy-agent: npm install socks-proxy-agent, then use SocksProxyAgent("socks5://USER:PASS@gw.knoxproxy.com:7001").
Free trial on rotating residential -- 3 minutes setup, no credit card.