Proxy in Crawlee via ProxyConfiguration

In Crawlee a proxy is one ProxyConfiguration object that every crawler understands. Here is an HttpCrawler that prints the IP.

HTTPHTTPSLogin and passwordRotation and sticky
Crawlee · proxy
['http://LOGIN:PASSWORD@HOST:PORT']
new ProxyConfiguration(...)
true
✓ IP: Germany, residentialRun

Why use a proxy in Crawlee

Crawlee is a Node.js library for data collection and browser automation. The proxy is set via ProxyConfiguration with a proxyUrls list, accepted by HttpCrawler, CheerioCrawler, JSDOMCrawler, PlaywrightCrawler and PuppeteerCrawler. Crawlee rotates through the list by itself and can bind a proxy to a session.

What to pick

Take HTTP: Crawlee's HTTP crawlers work only with HTTP and HTTPS proxies. For bulk collection choose rotation. If you need a session-to-IP binding, use sticky sessions and useSessionPool.

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 Crawlee.

  1. Install Crawlee

    Run npm i crawlee. Browser crawlers also need playwright or puppeteer.

  2. Export the proxy

    Take login:pass@ip:port in @SousProxyBot or the dashboard and prepend http://. You can list several sticky sessions in proxyUrls.

  3. Create a ProxyConfiguration

    Pass the string in proxyUrls. Crawlee cycles through the addresses.

  4. Attach it to the crawler

    Set proxyConfiguration in the crawler options. requestHandler exposes proxyInfo with the current proxy.

  5. Run and check the IP

    Save the example as ip.mjs and run node ip.mjs. The log shows a response with the proxy IP.

Code example

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

js
import { HttpCrawler, ProxyConfiguration } from 'crawlee';

const proxyConfiguration = new ProxyConfiguration({
    proxyUrls: ['http://LOGIN:PASSWORD@HOST:PORT'],
});

const crawler = new HttpCrawler({
    proxyConfiguration,
    additionalMimeTypes: ['application/json'],
    async requestHandler({ body, proxyInfo, log }) {
        log.info(`Proxy: ${proxyInfo?.hostname}, response: ${body.toString()}`);
    },
});

await crawler.run(['https://api.ipify.org?format=json']);

Tested by running it

We ran this example ourselves: Node.js 22.23.5 · crawlee 3.18.2. Real output below, IP hidden.

Terminal · main.js
$ node main.js
INFO  HttpCrawler: Starting the crawler.
INFO  HttpCrawler: Proxy: HOST, response: {"ip":"proxy IP"}
INFO  HttpCrawler: All requests from the queue have been processed, the crawler will shut down.
INFO  HttpCrawler: Final request statistics: {"requestsFinished":1,"requestsFailed":0,"retryHistogram":[1],"requestAvgFailedDurationMillis":null,"requestAvgFinishedDurationMillis":144,"requestsFinishedPerMinute":261,"requestsFailedPerMinute":0,"requestTotalDurationMillis":144,"requestsTotal":1,"crawlerRuntimeMillis":230}
INFO  HttpCrawler: Finished! Total 1 requests: 1 succeeded, 0 failed. {"terminal":true}

And this is the response when the password is wrong:

$ node main.js
…
INFO  HttpCrawler: All requests from the queue have been processed, the crawler will shut down.
INFO  HttpCrawler: Final request statistics: {"requestsFinished":0,"requestsFailed":1,"retryHistogram":[null,null,null,null,null,null,null,null,null,null,1],"requestAvgFailedDurationMillis":3,"requestAvgFinishedDurationMillis":null,"requestsFinishedPerMinute":0,"requestsFailedPerMinute":188,"requestTotalDurationMillis":3,"requestsTotal":1,"crawlerRuntimeMillis":319}
INFO  HttpCrawler: Error analysis: {"totalErrors":1,"uniqueErrors":1,"mostCommonErrors":["1x: Detected a session error, rotating session... (/home/user/proxy-test/node_modules/@crawlee/http/internals/http-crawler.js:461:23)"]}
INFO  HttpCrawler: Finished! Total 1 requests: 0 succeeded, 1 failed. {"terminal":true}

Common errors

The issues people most often bring to support.

!

Proxy URL protocol "socks5:" is not supported. Please use HTTP or HTTPS.Crawlee's HTTP crawlers don't do SOCKS. Export the proxy with the HTTP protocol.

!

Content-Type application/json is not supportedHttpCrawler and CheerioCrawler expect HTML by default. Add additionalMimeTypes: ['application/json'] as in the example.

!

407 response and request retriesCheck the login and password in the URL. Encode special characters with encodeURIComponent.

!

Site blocks after a few requestsEnable useSessionPool and persistCookiesPerSession: Crawlee rotates the session on a block. For rotation on our side choose rotation mode.

Need a proxy for Crawlee?

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

FAQ

How do I set a proxy for PlaywrightCrawler?

The same way: pass the same proxyConfiguration to new PlaywrightCrawler({ proxyConfiguration, ... }). Crawlee hands the login and password to the browser itself.

Can I bind an IP to a session?

Yes, Crawlee pins a proxy to a sessionId. With several sticky lines in proxyUrls, each session keeps its own.

How do I check requests go through the proxy?

Print proxyInfo in requestHandler and compare the IP from the response with /en/tools/my-ip/.