The approach
Node's HTTP clients use agents to route traffic through proxies. For Rayobyte, create an agent from the proxy URL in the dashboard (http://USERNAME:PASSWORD@HOST:PORT) and pass it to your client. Keep the URL in an environment variable. Our general Node.js and Axios proxies guide covers the concepts.
Axios
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent(process.env.RAYOBYTE_PROXY);
const res = await axios.get("https://httpbin.org/ip", {
httpsAgent: agent,
proxy: false, // let the agent handle proxying
timeout: 30000,
});
console.log(res.data);Setting proxy: false stops Axios's own proxy handling from interfering with the agent.
Native fetch (undici)
import { ProxyAgent, fetch } from "undici";
const dispatcher = new ProxyAgent(process.env.RAYOBYTE_PROXY);
const res = await fetch("https://httpbin.org/ip", { dispatcher });
console.log(await res.json());Got
import got from "got";
import { HttpsProxyAgent } from "https-proxy-agent";
const data = await got("https://httpbin.org/ip", {
agent: { https: new HttpsProxyAgent(process.env.RAYOBYTE_PROXY) },
timeout: { request: 30000 },
}).json();Sticky sessions
Build the username from the dashboard's template with a session ID per task. Create a new agent per session:
import { randomUUID } from "node:crypto";
function sessionAgent(template) {
const sid = randomUUID().slice(0, 10);
return new HttpsProxyAgent(template.replace("{session}", sid));
}If the residential IP drops mid-task, create a new agent and retry. See Rayobyte sticky sessions.
Residential tip: Before scaling, run a short pilot with Rayobyte on your real targets and record success rate, latency and GB per result. Our our complete Rayobyte guide explains which Rayobyte product fits which job.
SOCKS5
Use socks-proxy-agent with a socks5h:// URL so DNS resolves through the proxy:
import { SocksProxyAgent } from "socks-proxy-agent";
const agent = new SocksProxyAgent("socks5h://user:pass@HOST:PORT");See SOCKS5, UDP and protocol support.
Concurrency
Use a limiter such as p-limit to cap requests in flight:
import pLimit from "p-limit";
const limit = pLimit(50);
const results = await Promise.allSettled(urls.map((u) => limit(() => fetchPage(u))));Size it to your plan: unlimited on Premium Residential, one request per dollar on Scale Residential and monthly rotating ISP. See concurrency and threads.
Retries and block detection
Wrap requests in a retry helper that treats CAPTCHA pages and 403 or 429 responses as failures, starts a new session, and gives up after two or three tries. Check for content you expect rather than relying on status codes.
Routing by domain
Keep a map of domain to proxy URL so easy domains use rotating datacenter and protected ones use Premium Residential. See Rayobyte for web scraping.
Proxy tip: If your residential usage goes up and down, compare Geonode: its per-GB residential bandwidth doesn't expire, so you only pay for what you use. See using Geonode with Node.js.
Browsers
For JavaScript-heavy pages, see Rayobyte with Puppeteer and Rayobyte with Playwright. Our Puppeteer proxies guide covers the full setup.
How it compares
See Rayobyte vs Geonode for Node.js, Rayobyte vs Webshare for Node.js and all three for Node.js.
Before you commit to any provider, it helps to see the wider market: our guide to the best proxies in 2026 compares proxy types by job, and cheap proxies explains how to keep costs down without buying IPs that get blocked.
Budget tip: If you want a cheap proxy to try this with, Webshare has a free plan with 10 datacenter proxies and 1 GB of bandwidth a month, no card required. Paid lists let you pick proxy count, bandwidth and location. See using Webshare with Node.js.
Key takeaways
- Use proxy agents: HttpsProxyAgent for Axios and Got, undici's ProxyAgent for fetch.
- Set
proxy: falsein Axios when using an agent. - Create a new agent per sticky session and retry on drops.
- Cap concurrency with a limiter sized to your plan.
FAQ
Why does Axios ignore my Rayobyte proxy?
Usually because Axios's built-in proxy option conflicts with the agent. Set proxy: false.
Can I use Rayobyte with native fetch?
Yes, through undici's ProxyAgent as a dispatcher.
How do I rotate IPs?
Use a rotating gateway, or change the session ID and create a new agent.
Editorial note: Proxy providers change their pools, features and prices often, so treat any figures here as typical ranges at the time of writing and confirm current terms with the provider before you buy.