Back to blog
Web scrapingSep 11, 2026

IP Rotation for Web Scraping: A Practical 2026 Guide

EProxies Data Solutions Team·Public-web data collection research·7 min read
best-practices-for-rotating-ip-addresses-in-web-scraping

TL;DR: Rotate IPs between independent tasks, not between steps that share cookies or server-side state. Configure a proxy gateway, choose rotating or sticky sessions, cap retries, honor Retry-After, and validate the returned content. Judge the system by cost per valid record—not by IP count or rotation frequency.

IP Rotation Setup

How IP Rotation Works

A rotating proxy gateway assigns an eligible exit IP according to the session policy attached to each request. The gateway may change the IP for every independent request, preserve it under a sticky-session ID, or replace it after the session expires. Your scraper still controls concurrency, cookies, retries, and content validation.

Use two explicit session models:

  • Rotating session: Request a new eligible route for each independent URL or job.
  • Sticky session: Preserve one route for a workflow that depends on cookies, account state, request order, or a consistent location.

Targets can evaluate more than the source IP. Request rate, cookies, account identity, URL sequence, headers, TLS characteristics, and geography may all affect the response. Changing only the IP will not repair an expired login, invalid cookie, excessive request rate, or unauthorized request.

Match Rotation to the Unit of Work

Because the session policy must reflect the workflow, define the unit of work before choosing a rotation interval. A product-page lookup may require one request; a cart-price check may require five ordered requests using one cookie jar and one country. Rotating halfway through the second workflow can change currency, inventory, tax, or session state.

WorkflowRecommended policyRotation point
Independent public pagesRotatingAfter each completed URL
Search plus paginated resultsStickyAfter the result set finishes
Login or account workflowStickyAfter logout or session expiry
Product page plus cartStickyAfter the cart record validates
Country comparisonRotating, country pinned per taskBetween country-specific tasks
Large API queueRotating with domain throttlingBetween independent API calls

Independent requests

Rotate between public articles, directory records, product pages, or localization checks that do not share cookies. Apply a separate concurrency limit to each domain; a pool with thousands of available IPs does not justify sending thousands of simultaneous requests to one host.

Stateful workflows

Bind the proxy session, cookie jar, user agent, account identity, and assigned country into one session object. Rotate that complete object only when the workflow finishes or becomes irrecoverably invalid.

import requests

def build_sticky_session(proxy_url: str) -> requests.Session:
    session = requests.Session()
    session.proxies.update({
        "http": proxy_url,
        "https": proxy_url,
    })
    session.headers.update({
        "User-Agent": "AuthorizedResearchClient/1.0",
        "Accept-Language": "en-US,en;q=0.8",
    })
    return session

session = build_sticky_session(sticky_proxy_url)

product = session.get(product_url, timeout=(5, 20))
cart = session.get(cart_url, timeout=(5, 20))

If the cart request depends on a cookie set by the product request, both calls must use the same session. A new IP with the old cookie can create an inconsistent identity; a new IP with a new cookie loses the cart state entirely.

Geographic collection

Pin one country for every request contributing to a record. For example, a price record assembled from a product page, delivery estimator, and cart must not switch countries between steps.

According to EProxies’ provider-published product information, its residential network includes 72M+ IPs across 195+ countries. Those figures describe advertised network coverage, not the number of IPs simultaneously available for a particular country, domain, or session. Verify eligible locations in the current dashboard before sizing a job.

Set Up IP Rotation Step by Step

Once the unit of work is defined, a working setup requires six decisions: protocol, authentication, rotation mode, location, concurrency, and failure handling. Record them in configuration rather than scattering them throughout crawler code.

1. Create the proxy endpoint

Select HTTP(S) or SOCKS5 in the provider dashboard and copy the generated gateway hostname, port, username, and password. Keep credentials in environment variables or a secrets manager, never in source code, screenshots, exception messages, or repository history.

export EPROXIES_HOST="gateway.example"
export EPROXIES_PORT="10000"
export EPROXIES_USER="account-user"
export EPROXIES_PASS="account-password"

Use the actual hostname and port generated for the account; the values above are placeholders.

2. Configure the HTTP client

Python’s requests client accepts one proxy mapping for both HTTP and HTTPS destinations. The five-second connect timeout prevents a dead route from occupying a worker, while the 20-second read timeout limits how long the worker waits after connecting.

import os
import requests

proxy_url = (
    f"http://{os.environ['EPROXIES_USER']}:"
    f"{os.environ['EPROXIES_PASS']}@"
    f"{os.environ['EPROXIES_HOST']}:"
    f"{os.environ['EPROXIES_PORT']}"
)

proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

response = requests.get(
    "https://example.com/public-page",
    proxies=proxies,
    timeout=(5, 20),
)
response.raise_for_status()

For SOCKS5, install the client’s SOCKS support and use a socks5h:// URL when DNS resolution should occur through the proxy. Confirm the protocol syntax against the generated dashboard configuration rather than assuming that HTTP and SOCKS5 share a port.

3. Select rotating or sticky behavior

For independent tasks, use the provider’s rotating endpoint or generate a fresh session according to the dashboard instructions. For stateful tasks, create one sticky-session ID and reuse it with the same requests.Session, cookie jar, country, and headers until the workflow finishes.

Provider-specific session syntax varies, so do not invent username parameters. Generate or copy the exact rotating and sticky credentials shown in the account dashboard, then store each as a separate secret, such as EPROXIES_ROTATING_URL and EPROXIES_STICKY_URL.

4. Add domain-level concurrency limits

Begin with one to three workers per domain, then increase only if validation success remains stable and the target’s published limits permit it. Keep global worker count separate from per-domain worker count: 100 workers can process 20 domains at five workers each without directing all 100 connections to one host.

In EProxies’ preflight workflow, a canary queue runs before the full job is released. Each canary records the proxy session, country, domain, status, latency, bytes, retry count, and validation result so a transport success cannot conceal a consent page or incorrect regional response.

5. Apply bounded retries

Classify the result before deciding whether a new route can help. The HTTP semantics for Retry-After and status codes are defined in RFC 9110.

ResultActionRotate immediately?
Connect timeoutBack off, then retryYes, after one failed route
HTTP 408Retry only an idempotent requestUsually
HTTP 429Honor Retry-After; reduce concurrencyNo
HTTP 500/502/503/504Retry with a two- or three-attempt capOptional
HTTP 401Check authorization or account stateNo
HTTP 403Stop the retry loop and review accessNo
HTTP 407Correct proxy credentials or allowlistNo
HTTP 200 with invalid contentClassify the page before retryingDepends on cause

Use capped exponential backoff with jitter:

delay_seconds = min(30, 2^attempt + random(0, 1))

Ten immediate retries through ten IPs still create ten failed requests. They also consume bandwidth and can turn a brief rate limit into a prolonged failure.

Diagnose Rotation Failures by Cause

Those retry decisions should follow diagnosis rather than substitute for it. Keep transport health, target responses, and content validity as separate fields; combining them into one “success rate” hides whether the proxy, target, or parser failed.

Session or identity drift

Symptoms include redirected logins, empty carts, changed language, and pagination that repeatedly returns page one. Compare the current proxy session, cookie-jar ID, user agent, account, and country with the values recorded at the start of the workflow.

Pool pressure

A country-specific queue can exhaust its eligible routes before the broader network is constrained. Reduce workers, increase the cooldown interval, split the queue by time window, or broaden the location only when the research specification permits it.

HTTP 429 rate limits

Parse Retry-After as either seconds or an HTTP date, then pause the affected domain. Do not move the same queue to fresh IPs while retaining the same request rate.

HTTP 403 access denials

Verify that the requested resource is public and authorized for collection. A 403 may reflect access policy, authentication, or a technical control; repeatedly changing IPs does not establish permission.

HTTP 407 proxy authentication errors

Check the gateway hostname, port, protocol prefix, URL encoding, credentials, and any configured IP allowlist. Test one minimal request before returning the worker to the queue.

Unstable routes

Move endpoints through a controlled lifecycle instead of permanently discarding one after a timeout:

healthy → degraded → cooldown → probe → healthy

For example, mark a route degraded after two connection failures within five minutes, cool it down for ten minutes, and restore it only after a successful probe. Tune those thresholds from observed traffic rather than treating them as universal defaults.

Validate Records Before Counting Success

Diagnosis is incomplete until the returned content is checked. An HTTP 200 response proves that bytes arrived; it does not prove that the correct record arrived. A consent screen, login template, regional redirect, empty JavaScript shell, or error message can all return status 200.

Use a control loop that evaluates transport and content separately:

select session
→ send request
→ classify status
→ validate required fields
→ update route and domain scores
→ complete, retry, or cooldown

For a product record, validation might require all of these conditions:

  • Product ID matches the requested URL.
  • Currency matches the assigned country.
  • Price parses as a number within an expected range.
  • Availability contains an accepted value.
  • Response is not a login, consent, or challenge template.
  • Structured data and visible content do not materially conflict.

Track gateway connection success, target HTTP success, validation success, p50 and p95 latency, retries per valid record, bytes per valid record, and cost per valid record. Segment each metric by domain, country, and rotating versus sticky mode.

Start with 20–100 representative URLs. Define stop thresholds before the run—for example, pause expansion if validation falls below 95%, p95 latency exceeds 15 seconds, or more than 5% of responses return 429. These are initial operational thresholds, not guarantees; adjust them to the target and completeness requirements.

Separate Provider Metrics From Application Results

Application-level measurements should also remain separate from provider metrics. EProxies publishes a 98.2% uptime figure backed by a 99.9% uptime SLA. These are provider-reported service figures; the SLA’s exclusions, measurement window, remedy, and eligible products depend on the current contract, so review the operative terms before treating 99.9% as an application guarantee.

Proxy-gateway uptime differs from target success. A gateway can be available while a target returns 429, a page renders without required fields, or a country-specific route produces the wrong catalog. Keep SLA monitoring separate from valid-record rate.

Control Bandwidth and Record Cost

The distinction matters financially as well as operationally. Traffic-based plans bill transferred bytes, including unsuccessful responses and, depending on the plan’s accounting rules, retries or browser assets. A 3 MB rendered page retried three times transfers roughly 9 MB before producing one record; blocking unnecessary video, images, and fonts can change the economics more than a small per-GB price difference.

Calculate the unit that matters:

cost per valid record =
total proxy spend ÷ validated record count

Reduce that cost by deduplicating URLs, caching unchanged responses, requesting compressed content, blocking unnecessary browser assets, limiting response size, and enforcing retry caps. For API-led pipelines, see API-Driven Web Scraping for Industry Reports in 2026. JavaScript-dependent validation is covered in Web Scraping with AI for Dynamic Websites in 2026.

EProxies’ provider-published pricing lists pay-as-you-go residential access from $0.25/GB, tiered pricing of approximately $0.73/GB at 300GB, ISP SOCKS5 from $0.95/IP, and unlimited plans from $79 per month. These products use different billing units and may have separate conditions; confirm current prices, included traffic, location availability, concurrency rules, and renewal terms in the dashboard before comparing projected costs.

Tools for Implementing IP Rotation

With the operating model established, choose tools by workload rather than forcing every job into a browser. Plain HTTP clients transfer fewer bytes; browser automation handles JavaScript and interactive state but consumes more memory, CPU, and proxy traffic.

  • requests: Simple synchronous HTTP(S) collection and sticky cookie sessions.
  • httpx or aiohttp: Async workloads with explicit connection and concurrency controls.
  • Scrapy: Queues, downloader middleware, throttling, retries, and item validation.
  • Playwright: Browser contexts for JavaScript-heavy, cookie-bound workflows.
  • Redis: Shared queues, sticky-session locks, cooldown state, and retry scheduling.
  • OpenTelemetry: Request traces connecting a task, proxy session, retry, and validation result.
  • Prometheus and Grafana: Time-series monitoring for latency, 429 rates, validation failures, and bandwidth.

A beginner building a first controlled collector can compare client and framework choices in Web Scraping Tools for Beginners: 2026 Guide.

Compliance Boundaries

Whatever the implementation stack, IP rotation changes only network routing; it does not grant authorization or override authentication, paywalls, access controls, privacy obligations, or contractual restrictions. Confirm that each page and data category may be collected, enforce domain-level rate limits, and stop the job when permission is unclear.

Minimize personal data and document the collection purpose, lawful basis, retention period, access controls, and deletion procedure where privacy law applies. Requirements differ by jurisdiction and data type; use the Web Scraping Legality by Country: 2026 Map as a research starting point and obtain qualified advice for the actual workflow.

FAQ

What is IP rotation in web scraping?

IP rotation sends separate tasks through different proxy exit IPs instead of one fixed address. Rotation can occur per independent request, after a batch, when a sticky session expires, or after a qualifying connection failure.

Why is IP rotation useful?

Rotation distributes independent jobs across eligible routes and supports country-specific collection. It can also keep one failed route from blocking a queue, but it does not replace throttling, authorization checks, session management, or content validation.

Should a scraper rotate IPs on every request?

Only when the requests are independent. For logins, pagination, carts, searches, and multi-step forms that share state, keep the same IP, cookie jar, user agent, account identity, and country.

How do you set up IP rotation?

Create an HTTP(S) or SOCKS5 endpoint in the proxy dashboard, store its credentials securely, and configure the client’s proxy URL. Use the rotating endpoint for independent requests; for stateful work, reuse the dashboard-generated sticky-session ID with one cookie jar until the workflow finishes. Add per-domain concurrency limits, bounded retries, timeouts, and content validation before releasing the full queue.

Which tools help with IP rotation?

Use requests for synchronous jobs, httpx or aiohttp for async clients, Scrapy for queue and middleware control, and Playwright for JavaScript-dependent sessions. Redis can coordinate sticky-session locks and cooldowns across workers, while OpenTelemetry, Prometheus, and Grafana expose latency, retry, bandwidth, and valid-record metrics.

What are common IP rotation challenges?

Frequent problems include session breakage, country drift, pool pressure, unstable routes, proxy-authentication errors, rate-limit retry storms, and wasted bandwidth. Diagnose the response first: a 407 requires corrected credentials, a 429 requires slower traffic, and a stateful workflow usually requires the same IP until completion.

How do you configure proxy rotation?

Connect the HTTP client or crawler to the generated HTTP(S) or SOCKS5 gateway and select rotating or sticky credentials in the provider dashboard. Log the task ID, session ID, country, domain, status, latency, retry count, transferred bytes, and content-validation result.

How should a scraper respond to HTTP 429?

Honor Retry-After, pause the affected domain, reduce concurrency, and apply capped exponential backoff. Do not rapidly resend the same request through a sequence of new IPs.

What should happen after an HTTP 403?

Stop repeated automatic retries and review whether access is permitted. Verify authorization, authentication state, applicable terms, and technical access controls instead of assuming that another IP will resolve the response.

How should proxy performance be measured?

Track gateway connections, target HTTP responses, valid records, p50 and p95 latency, retries, transferred bytes, and cost per valid record. Segment results by domain, country, and sticky versus rotating session mode so one strong workload does not conceal another workload’s failures.

No. Rotation does not override privacy, copyright, contract, database, or computer-access laws. The workflow must still respect authorization requirements, technical controls, applicable terms, rate limits, and data-protection obligations.

This article was written by the EProxies team and reviewed against our editorial quality standards before publishing.