PRIVATEBYTE
ServersProxiesAgentsStatusNetworkAboutFree Proxies
Sign inDeploy

← Docs / Proxies

Datacenter proxies with Node.js

Node's built-in fetch does not read proxy settings, so you hand it a proxy agent. This page uses undici's ProxyAgent and the datacenter tier: a US datacenter IP that changes for every new connection.

What you need

  • Your proxy API key, from the Proxies page in the portal.
  • Node 18 or later, and npm install undici.
export PB_PROXY_KEY="YOUR_KEY"

Send a request through the proxy

import { ProxyAgent, fetch } from "undici";

const token =
  "Basic " + Buffer.from(`${process.env.PB_PROXY_KEY}:datacenter`).toString("base64");

const agent = new ProxyAgent({ uri: "http://proxy.privatebyte.com:3128", token });

const res = await fetch("https://api.ipify.org", { dispatcher: agent });
console.log(await res.text()); // a US datacenter address

await agent.close();

The token is the proxy login: your API key and the tier, base64 encoded.

One IP, or a new one each time

An agent keeps its connections open. Every request through the same agent leaves from the same address. Create a new agent to get a new one:

for (let i = 0; i < 3; i++) {
  const agent = new ProxyAgent({ uri: "http://proxy.privatebyte.com:3128", token });
  console.log(await (await fetch("https://api.ipify.org", { dispatcher: agent })).text());
  await agent.close();
}

Reuse one agent when a site expects a steady address, or when you want a cheaper bill: a new HTTPS connection costs about 4 KB of handshake. See how usage is counted.

Errors

What you see What it means
407 Proxy Authentication Required The API key is wrong or missing.
400 with Unknown tier "datacentre" The tier word is a close misspelling of a real tier. Fix the spelling. A password that is not close to any tier, such as x, uses your account's default tier.
400 Invalid proxy password settings The password asked for something this tier does not do: a country other than US, a session or a TTL.
A site returns 403 The site is refusing datacenter addresses. Try a residential tier such as standard.

Related

  • Datacenter proxies with Playwright
  • Datacenter proxies with Puppeteer
  • How rotating proxies work
  • Datacenter proxies

Try your next connection.

Free proxy credit for eligible new proxy users. No card required. Review the amount and conditions before claiming.

Get free proxy credit →

Explore proxy tiers and paid credit

Related

Proxies: your first requestFind your credentials, copy a cURL or Python example, and check the response.Proxy connection format and tiersWhat goes in the username and password, and what each tier is for.Using SOCKS5Port 1080, the same credentials, and the two things SOCKS5 cannot do.

Still stuck? Open a ticket — tell us what was missing and the article gets fixed.

PRIVATEBYTE

Infrastructure for independent minds.

Service status

Products

Virtual serversProxiesGet free proxy creditAgentsMigration

Resources

Looking glassSecurityBlogNews

Free tools

What is my IPProxy checkerPort checkerDomain checkerDNS lookupPassword generatorVPS price calculator

Company

AboutContactX / TwitterTelegram
© 2026 PrivateByte Ltd
TermsPrivacyAcceptable useRefundsAbuse & legalSLA

Registered in England & Wales · Company no. 15834803 · 128 City Road, London EC1V 2NX