Skip to content
Esc

Articles

What is a proxy? A plain-English guide for beginners: how it works, the types, and what it's forWhat is a 4G proxy? How mobile proxies work, pros, cons and when to use oneRotating proxies explained: rotation types and how to change a proxy IP with a linkSOCKS5 vs HTTP proxies: what's the difference and which should you use?Proxy vs VPN: what's the difference, and when should you use each?Static vs rotating proxies: how they differ, pros and cons, and when to use eachDedicated vs shared proxies: how they differ, and what "dedicated" means for a 4G proxyIPv4 vs IPv6 proxies: how they differ, why IPv6 proxies are cheap, and when they don't workHow do websites detect proxies? 8 signals anti-bot systems look atProxy glossary A to Z: 35 terms you'll meet when buying and using proxies, explained simplyProxy vs antidetect browser: how they differ, and do you need a proxy if you have antidetect?What is a residential proxy? How it works, pros and cons, and when to use oneWhat is a datacenter proxy? Pros and cons, why it's cheap, and when it's still the right choiceHow to find your IP address on a computer or phone: public IP, local IP, and your IP behind a proxyWhy do you keep getting CAPTCHAs? 9 common triggers, and where your IP fits inreCAPTCHA vs hCaptcha vs Cloudflare Turnstile: how each one decides who gets challengedWhat is botting? Good bots, bad bots, and where your own automation fitsHow to get a Singapore IP address: VPN, proxy, cloud server or SIM, and how to check itProxies for Facebook: managing several accounts more reliably with 4G IPsProxies for TikTok and TikTok Shop: when you need a Singapore IP and how to use it properlyProxies for advertising: checking and managing ads aimed at SingaporeProxies for e-commerce sellers: see marketplaces like a buyer, track competitors, keep store logins steadyProxies for web scraping: which type to choose, how to rotate, and how to play fairDo you need a proxy to buy tickets on ThaiTicketMajor, Ticketmelon or SISTIC?Scraping Google and Bing search results with a proxy, and when to use the API insteadHow to scrape without getting blocked: pace, sessions and clean IPsProxies for price monitoring: tracking competitor and retail prices across regionsScraping anti-bot and anti-proxy websites (Cloudflare, Akamai, DataDome): what works, and the limitsIs web scraping legal? Robots.txt, terms, personal data and copyright (Vietnam, Singapore and beyond)What are 4G proxies used for? 10 jobs mobile proxies do well, and the ones to avoid4G proxies for testing apps and websites as a Singapore mobile user: QA, ads, payments, bot rulesProxies for Instagram: managing brand and client accounts steadily with 4G IPsUsing a proxy to check flight and hotel prices as a Singapore user: when it helps and what to knowResearching the Singapore market with a proxy: see search, ads, marketplaces and competitors as a local userProxies for LinkedIn: managing B2B accounts and reaching the Singapore market the right wayProxies for X (Twitter): managing brand and client accounts steadily and within the rulesProxies for airdrops: why farming wallets through proxies gets disqualified, and how to join airdrops safelyProxies for seeding, bought likes and fake reviews: why they get caught, the risks, and lasting ways to growProxies for flash sales and limited drops: what a proxy can and can't do, and how to shop sales properlyProxies for large-scale, multi-country scraping: choosing proxy types, system design and real costsProxies for Netflix, YouTube and foreign streaming: why they usually fail, cost a lot, and what to do insteadSelling to Singapore from Vietnam: choosing channels, GST, shipping, payments and the tools you needSelling on TikTok Shop Singapore from abroad: seller requirements, workable routes and what a proxy can doThe Singapore online shopping market: who shops, where, how they pay and the big sale seasonsA workflow for agencies managing client accounts with proxies and antidetect: inventory, access, offboardingLocal SEO in Singapore: checking Google and Google Maps rankings as a Singapore user, the right wayProxies for Google Ads: when you need one, the official tools to use first, and the policy lines to knowRoblox lagging, high ping: does a proxy help, and the fixes that really reduce Roblox lagMultiple Roblox accounts (alts): what the rules allow and forbid, whether you need a proxy, and IP bansLag and high ping on Singapore game servers: do proxies or VPNs lower ping, and what actually helpsDiscord proxy: what it can and can't do, how to set it up, and managing communities the right wayShopee and Lazada Singapore proxies: see what Singapore buyers see, run your shop, track competitorsProxies for online business (MMO): which jobs need one, which type to pick and what to avoidProxy for bots and automation: one identity per IP, a polite pace, and what to do when a CAPTCHA appearsHow to set up a proxy on Windows, macOS, iPhone and Android (with a username and password)How to add a proxy to GoLogin, AdsPower, Hidemyacc, GenLogin and MultiloginRotate a proxy IP automatically with an API: curl, Python and Node.js examplesHow to check a proxy: IP, country, carrier, speed and DNS and WebRTC leaksCommon proxy errors and how to fix them: 407, timeouts, ERR_PROXY_CONNECTION_FAILEDScraping JavaScript-rendered sites with a headless browser and a proxy403, 429 and 503 errors when scraping: causes and how to handle them properly (with Python code)Using a proxy with Scrapy: authenticated setup, polite throttling, error fixes and rotating between runsUsing a proxy with curl and wget: HTTP, SOCKS5, authentication, environment variables and debuggingUsing a proxy in Python: requests, httpx and aiohttp with HTTP, SOCKS5 and authenticationSetting up a proxy in Chrome and Edge: a browser-only proxy without changing the whole computerSingapore proxy for Telegram: set up SOCKS5 on desktop, iPhone and Android, and how it differs from MTProtoSlow 4G proxy? How to measure speed and latency properly, and what really makes a proxy fasterUsing proxies safely: protect your proxy password, rotation link, accounts and dataUsing Proxifier for software without proxy support: SOCKS5 setup, per-app rules and DNSRoblox proxies for developers: calling Roblox APIs from HttpService, Open Cloud, and a safe self-hosted relayProtecting your Roblox account: cookie theft, "free Robux", malicious extensions, and how to stay safeHow to set up a proxy in AdsPower: HTTP or SOCKS5, where to paste it, checking the Singapore IP and rotatingHow to add a proxy to GoLogin: HTTP or SOCKS5, where to enter it, checking the Singapore IP and rotatingHow to add a proxy to GenLogin: HTTP or SOCKS5, where to paste it, checking the Singapore IP and rotatingHow to add a proxy to Hidemium: HTTP or SOCKS5, where to enter it, checking the Singapore IP and rotatingHow to add a proxy to BitBrowser: HTTP or SOCKS5, where to enter it, checking the Singapore IP and rotatingCAPTCHA keeps appearing or loops forever: 8 fixes, in the order to try themMobile vs residential vs datacenter proxies: comparing 4G, home and server IPs, and how to chooseSingapore proxies: when you need a Singapore IP and which type to chooseClean proxies and blacklists: what a clean IP means, and why "never blocked" is a myth4G rotating proxies: how mobile IP rotation works, what clean rotation means and how to choose oneHow to tell a real 4G proxy from a fake: check the carrier, IP type, latency and rotationFree vs paid proxies: the real risks of free proxies, and when paying is worth itDedicated 4G proxies, not shared: why a proxy only you use matters, and how to check it yourselfHow many proxies do I need? Working out the number for accounts, teams and scrapingStatic IP proxies for allowlists, APIs and remote access: 5 options and how to choose the right oneVietnam or Singapore proxy? Choosing which country's IP fits your workSingtel, M1 and StarHub proxies: which Singapore carrier a 4G proxy runs on, and how to check itClean proxy and CAPTCHA: how IP reputation decides how many challenges you seeThe real cost of a dirty proxy: CAPTCHAs, retries, wasted bandwidth and blocked accountsSingapore SOCKS5 proxy: when to use it, how to set it up, and how to check it5G proxy vs 4G proxy: what changes, what doesn't, and whether 5G is worth paying more forCheap 4G proxies: $4 gets you 200GB, and how to compare mobile proxy prices properly before you buyRefer a friend and earn 10% on every proxy order: how the 65Proxy referral program worksWhy choose 65Proxy? 8 reasons you can verify, and when you should go elsewhereHow to buy a 4G proxy at 65Proxy: sign up, top up, pay, connect and rotate, step by stepWhere to buy a reliable proxy? 12 things to check before paying any providerTesting a 4G proxy in a 1-hour trial: a minute-by-minute checklistBuy proxies with USDT: paying for a Singapore 4G proxy over TRC20 or BEP20, step by step4G proxy with 500GB: what the plan includes, how far 500GB goes, and how bandwidth is countedGuides to 4G mobile proxies

Rotate a proxy IP automatically with an API: curl, Python and Node.js examples

Setup and use 5 min read

In this article
  1. 01 How it works: one link, one GET request
  2. 02 Rotating with curl
  3. 03 Python with requests
  4. 04 Node.js with undici
  5. 05 Playwright and Puppeteer
  6. 06 Tips for automation

Opening a rotation link in a browser is easy, but once you run tools, scrapers or a series of browser profiles, rotation should be automatic: call the link, wait for the proxy to reconnect, confirm the IP changed, and only then carry on. This guide has ready-to-run code for curl, PowerShell, Python and Node.js, and shows how to use a password-protected proxy with Playwright and Puppeteer.

How it works: one link, one GET request

With 65Proxy's 4G proxies, every proxy has its own rotation link under My proxies. The "rotation API" is that link: send a GET request to it (directly, not through the proxy), and the 4G device reconnects to the mobile network and gets a new IP.

All the code below follows the same rhythm:

  1. Get the current IP through the proxy (using https://api.ipify.org, which returns nothing but the IP address).
  2. Call the rotation link.
  3. Wait and re-check every few seconds until the IP differs from the old one or time runs out.

Step 3 matters more than it looks: the device needs a few seconds to reconnect, and requests through the proxy may fail meanwhile. Don't rely on whatever the rotation link returns. Check that the IP actually changed.

In the examples, USER, PASS, HOST and PORT are your proxy details, and the rotation link is read from the ROTATE_URL environment variable. Don't hard-code the link: anyone who has it can rotate your IP.

Rotating with curl

On macOS, Linux or Git Bash on Windows:

Terminal
export PROXY="http://USER:PASS@HOST:PORT"
export ROTATE_URL="YOUR_ROTATION_LINK"

old=$(curl -s -m 15 -x "$PROXY" https://api.ipify.org)
curl -s -m 60 "$ROTATE_URL" > /dev/null

# Re-check every 3 seconds, for about a minute at most
for i in $(seq 1 20); do
  sleep 3
  new=$(curl -s -m 10 -x "$PROXY" https://api.ipify.org)
  if [ -n "$new" ] && [ "$new" != "$old" ]; then
    echo "$old -> $new"
    break
  fi
done

On Windows PowerShell

In Windows PowerShell, curl is an alias for a different command (Invoke-WebRequest), so type curl.exe (the real curl that ships with Windows 10 and 11):

PowerShell
$proxy  = "http://USER:PASS@HOST:PORT"
$rotate = $env:ROTATE_URL

$old = curl.exe -s -m 15 -x $proxy https://api.ipify.org
curl.exe -s -m 60 $rotate | Out-Null

foreach ($i in 1..20) {
  Start-Sleep -Seconds 3
  $new = curl.exe -s -m 10 -x $proxy https://api.ipify.org
  if ($new -and $new -ne $old) { "$old -> $new"; break }
}

Python with requests

Install the library with pip install requests, set the PROXY and ROTATE_URL environment variables, and run:

Python
import os
import time

import requests

PROXY = os.environ["PROXY"]            # http://USER:PASS@HOST:PORT
ROTATE_URL = os.environ["ROTATE_URL"]  # the rotation link from My proxies
PROXIES = {"http": PROXY, "https": PROXY}


def current_ip() -> str:
    r = requests.get("https://api.ipify.org", proxies=PROXIES, timeout=15)
    r.raise_for_status()
    return r.text.strip()


def rotate(wait: float = 60) -> str:
    """Call the rotation link, then wait until the proxy has a new IP."""
    old = current_ip()
    requests.get(ROTATE_URL, timeout=60).raise_for_status()
    deadline = time.monotonic() + wait
    while time.monotonic() < deadline:
        time.sleep(3)
        try:
            new = current_ip()
        except requests.RequestException:
            continue  # the proxy is reconnecting
        if new != old:
            return new
    raise TimeoutError("IP did not change within %d seconds" % wait)


if __name__ == "__main__":
    print("New IP:", rotate())

To use SOCKS5 instead of HTTP: also run pip install "requests[socks]" and set PROXY to socks5h://USER:PASS@HOST:PORT. The h makes the proxy resolve DNS, which avoids DNS leaks (explained in SOCKS5 vs HTTP proxies).

Setting environment variables in Windows PowerShell: $env:PROXY = "http://USER:PASS@HOST:PORT"; on macOS and Linux: export PROXY="http://USER:PASS@HOST:PORT".

Node.js with undici

Node.js's built-in fetch doesn't go through a proxy on its own. The undici library (from the Node.js project itself) has a ProxyAgent that accepts a proxy with the username and password in its URL. Install it with npm install undici, save the file as rotate.mjs and run node rotate.mjs:

JavaScript
import { fetch, ProxyAgent } from "undici";

const proxy = new ProxyAgent(process.env.PROXY); // http://USER:PASS@HOST:PORT
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function currentIp() {
  const res = await fetch("https://api.ipify.org", { dispatcher: proxy, signal: AbortSignal.timeout(15000) });
  return (await res.text()).trim();
}

async function rotate(waitMs = 60000) {
  const old = await currentIp();
  const res = await fetch(process.env.ROTATE_URL, { signal: AbortSignal.timeout(60000) });
  if (!res.ok) throw new Error("Rotation link answered " + res.status);
  for (const end = Date.now() + waitMs; Date.now() < end; ) {
    await sleep(3000);
    try {
      const ip = await currentIp();
      if (ip !== old) return ip;
    } catch {
      // the proxy is reconnecting
    }
  }
  throw new Error("The IP did not change in time");
}

console.log("New IP:", await rotate());

Playwright and Puppeteer

When you drive a browser from code, use an HTTP proxy: Chromium doesn't support SOCKS5 with a password.

Playwright (Python) takes the proxy, username and password when the browser launches (install with pip install playwright, then playwright install chromium):

Python
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(proxy={
        "server": "http://HOST:PORT",
        "username": "USER",
        "password": "PASS",
    })
    page = browser.new_page()
    page.goto("https://api.ipify.org")
    print(page.inner_text("body"))
    browser.close()

Puppeteer (Node.js) takes the proxy address as a launch argument and the username and password through page.authenticate:

JavaScript
import puppeteer from "puppeteer";

const browser = await puppeteer.launch({ args: ["--proxy-server=http://HOST:PORT"] });
const page = await browser.newPage();
await page.authenticate({ username: "USER", password: "PASS" });
await page.goto("https://api.ipify.org");
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();

To give each browser session its own IP: close the browser, rotate, then launch again. The browser keeps its connections to the proxy open, so rotating while it's running can break pages that are loading.

Tips for automation

  • One proxy is one IP at any moment. Every parallel worker on the same proxy shares the IP and gets cut off together when it rotates. Rotate only when no requests are in flight; for several IPs at once, use several proxies.
  • Always set timeouts and retries. Mobile networks have slow moments; one request hanging forever stalls the whole script.
  • Log the old and new IP on every rotation (invaluable when debugging).
  • Don't rotate constantly for no reason. Each rotation is a disconnect; rotate when the job calls for it, such as switching accounts or when a site starts limiting you.
  • Leave at least 5 minutes between rotations. Each 65Proxy proxy can rotate at most once every 5 minutes; calling the link sooner is refused (in Python, raise_for_status() raises). If your script rotates on a timer, make the interval 5 minutes or more.
  • Respect the sites you visit: read their terms and keep your request rate reasonable.

Not sure how rotation works under the hood? Read rotating proxies explained. Script failing to connect? See common proxy errors.