Rayobyte Guides

Using Rayobyte Proxies With Node.js: Axios, Fetch and Got

How to use Rayobyte proxies in Node.js with proxy agents for Axios, Got and native fetch (undici), plus sticky sessions, SOCKS5, concurrency control and retries.

By Team of Monkeys Editorial Updated 3 min read Affiliate disclosure

This guide contains affiliate links to Geonode, Webshare and Rayobyte. If you buy through them we may earn a commission, at no extra cost to you.

Rayobyte with Node.js illustration showing Node.js connecting through Rayobyte to Website, covering axios, fetch, got 3jdej38j4

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

javascript
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)

javascript
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

javascript
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:

javascript
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:

javascript
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:

javascript
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: false in 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.

Affiliate disclosure: Team of Monkeys is an affiliate of Geonode, Webshare and Rayobyte. Links and banners marked as sponsored, and links to Geonode, Webshare and Rayobyte in the text, use our referral links, and we may earn a commission if you buy through them, at no extra cost to you. Our explanations and comparisons are written to be useful whichever provider you choose.

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.