Node.js built-in fetch API with undici. Use the native fetch with KnoxProxy through a ProxyAgent for zero-dependency proxy support.
For the ProxyAgent dispatcher.
npm install undiciUse undici ProxyAgent.
const { ProxyAgent } = require('undici');
const agent = new ProxyAgent('http://USER:PASS@gw.knoxproxy.com:7000');Pass dispatcher to fetch.
const res = await fetch('https://httpbin.org/ip', { dispatcher: agent });
const data = await res.json();
console.log(data);Country in proxy URL username.
const deAgent = new ProxyAgent('http://USER-country-de:PASS@gw.knoxproxy.com:7000');Session ID in username.
const stickyAgent = new ProxyAgent('http://USER-session-abc:PASS@gw.knoxproxy.com:7000');Verify exit IP.
const res = await fetch('https://httpbin.org/ip', { dispatcher: agent });
console.log(await res.json());/**
* KnoxProxy + Node.js native fetch (undici ProxyAgent).
*/
import { ProxyAgent } from 'undici';
const agent = new ProxyAgent('http://USER:PASS@gw.knoxproxy.com:7000');
const res = await fetch('https://httpbin.org/ip', { dispatcher: agent });
const data = await res.json();
console.log('Exit IP:', data.origin);
// Country-targeted
const deAgent = new ProxyAgent('http://USER-country-de:PASS@gw.knoxproxy.com:7000');
const deRes = await fetch('https://httpbin.org/ip', { dispatcher: deAgent });
console.log('DE IP:', (await deRes.json()).origin);Each fetch call gets a fresh IP. Use -session-{id} in username for sticky sessions.
| Problem | Fix |
|---|---|
| UND_ERR_CONNECT_TIMEOUT | Check gateway host/port. Try increasing connect timeout. |
| fetch failed | Verify you are using { dispatcher: agent } in fetch options. |
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.
No. Node.js built-in fetch has no native proxy support, so a plain fetch() call ignores your KnoxProxy credentials entirely and connects directly to the target. You need the ProxyAgent from the undici package as the dispatcher option, built from your proxy URL, to route fetch requests through KnoxProxy at all, even on the newest Node.js versions.
Performance is roughly the same for proxied requests either way, since the network latency of the KnoxProxy round trip and the target site dominates the total time, not the HTTP client itself. Node built-in fetch with undici has slightly lower per-request overhead than Axios, but the difference is small enough that it rarely matters for scraping workloads.
Pass AbortSignal.timeout(30000) as the signal option on your fetch call to cap the whole request at 30 seconds, aborting it if the KnoxProxy gateway or target site takes too long to respond. Alternatively, set headersTimeout directly on the undici ProxyAgent constructor if you want the timeout to apply at the connection level instead.
Yes, but each runtime handles proxies differently from Node.js undici. Bun reads the standard http_proxy and https_proxy environment variables directly, no extra package needed. Deno instead requires the Deno.createHttpClient() API to build a client configured with your KnoxProxy proxy URL, then passes that client into fetch as the client option.
Rotating residential proxies -- 3 minutes setup, instant activation, 14-day money-back guarantee.