Setup Guides

How to Set Up Proxies in Scrapy

Route Scrapy traffic through an authenticated proxy in a few lines. Copy the code below and swap in your credentials.

Language Python Rotation Supported Category Scraping framework

Quick answer

Set the proxy in the format http://user:pass@host:port and send your Scrapy request through it. Full code below.

Scrapy proxy example

# settings.py
DOWNLOADER_MIDDLEWARES = {
    "scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware": 750,
}

# spider.py
def start_requests(self):
    yield scrapy.Request(
        "https://httpbin.org/ip",
        meta={"proxy": "http://user:pass@host:port"},
    )

Scrapy's built-in HttpProxyMiddleware routes any request whose meta['proxy'] is set, so a rotating gateway is as simple as assigning a new value per request. For large crawls pair it with a rotation middleware such as scrapy-rotating-proxies or a residential backconnect endpoint that rotates the exit IP server-side. Keep CONCURRENT_REQUESTS and AUTOTHROTTLE tuned to your proxy plan's session limits to avoid bans.

Rotating proxies

Scrapy works cleanly with rotating backconnect endpoints — point it at a single gateway host and the provider rotates the exit IP for you.

Best proxies to use with Scrapy

1

Cheapest-Proxies.com EDITOR'S CHOICE

4.9

Best overall value across every proxy type and use case · flexible pay-as-you-go plans

Visit Cheapest-Proxies.com
2

Bright Data

4.6

Enterprise-grade proxy and web data platform · from ~$8-9/GB (residential, volume-dependent)

Read Bright Data review
3

Oxylabs

4.6

Premium enterprise proxies and scraper APIs · from ~$8/GB (residential, volume-dependent)

Read Oxylabs review
4

Smartproxy

4.5

User-friendly proxies with excellent price-to-performance · from ~$3.50-7/GB (residential)

Read Smartproxy review

Our #1 pick is a sponsored partner. Remaining providers are ranked editorially by rating and value.

Frequently Asked Questions

How do I add a proxy in Scrapy?

Supply the proxy as http://user:pass@host:port and pass it to Scrapy as shown in the code above.

Can Scrapy rotate proxies automatically?

Yes — point it at a rotating backconnect endpoint and the provider rotates IPs for you.

Does Scrapy support authenticated proxies?

Yes. Provide the username and password (as a URL or separate fields) and Scrapy handles the auth handshake.

What proxies work best with Scrapy?

Residential or rotating proxies from a reliable provider give the best success rate for Python projects.

Related Guides

Best proxies for Scrapy

It ranked first for value in our comparison — see live pricing and plans.

Visit Cheapest-Proxies.com