Proxy in Scrapy via meta['proxy']

Scrapy works with proxies without third-party packages. Here is a spider that goes through a password proxy and prints the IP.

HTTPHTTPSLogin and passwordRotation and sticky
Scrapy · proxy
http://LOGIN:PASSWORD@HOST:PORT
enabled by default
✓ IP: Germany, residentialRun

Why use a proxy in Scrapy

Scrapy is a Python framework for crawling sites and collecting data. The built-in HttpProxyMiddleware takes the proxy from request.meta['proxy'] or from environment variables. It turns login and password in the proxy URL into a Proxy-Authorization header.

What to pick

Take an HTTP proxy: the built-in middleware doesn't support SOCKS5. For bulk collection enable rotation so each request can leave from a new IP. If the site binds a session to the address, use a sticky session.

Residential

from $0.6 / GB

Home ISP addresses. The main choice for accounts and protected sites.

VIP

$2 / GB

Hand-picked clean IPs, faster and more stable than regular residential.

Mobile

$4 / GB

Carrier IPs, for platforms that check addresses strictly.

Step-by-step setup

Button names are given exactly as they appear in Scrapy.

  1. Install Scrapy

    Run pip install scrapy. HttpProxyMiddleware is on by default; nothing to add to settings.py.

  2. Build the proxy string

    Export the login:pass@ip:port format in @SousProxyBot or the dashboard and prepend http://. If the password contains @ or :, encode them, e.g. with /en/tools/proxy-converter/ or urllib.parse.quote.

  3. Set the proxy in the request

    Pass meta={"proxy": "http://LOGIN:PASSWORD@HOST:PORT"} to scrapy.Request. For all requests of a spider, keep the string in a class attribute.

  4. Run the spider

    Save the example as ip_spider.py and run scrapy runspider ip_spider.py.

  5. Check the IP

    The log shows JSON from api.ipify.org with the proxy address. If it's your address, the meta didn't reach the request.

Code example

Put in your own HOST, PORT, LOGIN and PASSWORD from the bot or the dashboard.

python
import scrapy

PROXY = "http://LOGIN:PASSWORD@HOST:PORT"


class IpSpider(scrapy.Spider):
    name = "ip"

    async def start(self):  # Scrapy 2.13+; in older versions: def start_requests(self)
        yield scrapy.Request(
            "https://api.ipify.org?format=json",
            meta={"proxy": PROXY},
            dont_filter=True,
        )

    def parse(self, response):
        self.logger.info("IP: %s", response.text)

Tested by running it

We ran this example ourselves: Python 3.13.18 · Scrapy 2.20.0 · Twisted 26.10.0. Real output below, IP hidden.

Terminal · ip_spider.py
$ scrapy runspider ip_spider.py
2026-11-22 16:01:37 [scrapy.core.engine] INFO: Spider opened
2026-11-22 16:01:37 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2026-11-22 16:01:37 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2026-11-22 16:01:37 [scrapy.extensions.remote_control] INFO: Remote control HTTP server listening on port 46151 (job 2155-8a08e0cbfce14c5dad13b041c66292ac)
2026-11-22 16:01:37 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://api.ipify.org/?format=json> (referer: None)
2026-11-22 16:01:37 [ip] INFO: IP: {"ip":"proxy IP"}
2026-11-22 16:01:37 [scrapy.core.engine] INFO: Closing spider (finished)

And this is the response when the password is wrong:

$ scrapy runspider ip_spider.py
…
2026-11-22 16:01:37 [scrapy.core.scraper] ERROR: Error downloading <GET https://api.ipify.org/?format=json>
Traceback (most recent call last):
scrapy.core.downloader.handlers.http11.TunnelError: Could not open CONNECT tunnel with proxy HOST:PORT [{'status': 407, 'reason': b'Proxy Authentication Required'}]
2026-11-22 16:01:37 [scrapy.core.engine] INFO: Closing spider (finished)

Common errors

The issues people most often bring to support.

!

407 response from the proxyCheck the login and password in the URL. Special characters in the password must be URL-encoded, otherwise the string parses wrong.

!

Requests go out on your IPThe proxy isn't in the request meta or HttpProxyMiddleware is disabled in DOWNLOADER_MIDDLEWARES. Re-enable it and check meta['proxy'].

!

Error with socks5:// in meta['proxy']Scrapy's built-in middleware doesn't do SOCKS. Use an HTTP proxy from the same dashboard.

!

Timeouts on some requestsTest the proxy on /en/tools/proxy-checker/. With rotation some IPs are slower; RETRY_TIMES and a sensible DOWNLOAD_TIMEOUT help.

Need a proxy for Scrapy?

Residential, VIP and mobile IPs. HTTP and SOCKS5, pay per GB, 1 GB free to try.

FAQ

Can I set a proxy for the whole project at once?

Yes, HttpProxyMiddleware reads the http_proxy and https_proxy environment variables. But meta['proxy'] is clearer and lets you vary the proxy per request.

How do I get a new IP per request?

Export the proxy in rotation mode. The string stays the same; the address changes on the proxy side.

Do I need a separate proxy package?

Not for an HTTP proxy with a password; the built-in HttpProxyMiddleware is enough.