Skip to content
Get Started
G2G2
4.7/5
Excellent
Trustpilot

How to use proxies with Rust reqwest

Build a reqwest::Proxy and add it to the client: Client::builder().proxy(Proxy::all("http://HOST:PORT")?.basic_auth("USERNAME", "PASSWORD")).build()?. For SOCKS5 on static ISP proxies, enable reqwest's socks feature and use a socks5h:// URL.

  • Session Control
  • High Speed
  • Privacy First

What you need

reqwest is the usual HTTP client for Rust scrapers and services, async on Tokio with an optional blocking API. The proxy is set once on the Client, which also pools connections, so the main design choice is how many clients you build: one per ISP IP for stable identities, or clients without idle connections for rotation.

Your credential line

From the dashboard's proxy manager: host (or IP), port, username and password. Convert lists with the proxy list formatter.

Rust reqwest ready

  • Rust stable with Cargo, plus reqwest 0.13 and Tokio in Cargo.toml.
  • The socks feature on reqwest if you plan to use SOCKS5.

Which proxy fits Rust reqwest?

Both products use the same setup in Rust reqwest. What changes is how long an IP stays with you.

A Client pools connections behind one proxy, so a client built on one ISP line always exits from the same dedicated US IP. Keep one client per account (clones share the same pool) and turn on cookie_store(true) with the cookies feature for logged-in work.

starting from$0.75/IP

Dedicated static IPs registered to US and Canadian ISPs. The address stays the same for as long as you hold it, with unlimited bandwidth and HTTP(S) or SOCKS5 access.

A reused Client keeps connections alive, so a rotating line can return the same residential IP for several requests. Set .pool_max_idle_per_host(0) so every request opens a new connection and gets a new IP, or use a sticky line when a flow needs one IP.

starting from$0.63/GB

Residential IPs in 190+ countries with country, state and city targeting. Rotate on every request or hold a sticky session for up to 90 minutes; GB never expire.

credentials

Your CleanProxies credentials

Every product connects over HTTP(S); static ISP and ISP subnet proxies also run SOCKS5 and IP whitelisting. This is what the dashboard gives you to paste into Rust reqwest.

Static ISP and ISP subnetHTTP(S)SOCKS5IP whitelist
IP:PORT:USER:PASS

One line per dedicated IP. With IP whitelisting on, the line is just IP:PORT and no password is sent.

Rotating residential and mobileHTTP(S)User:pass
HOST:PORT:USER:PASS

Generated in the proxy manager. The username carries the location and session you pick, so generate a new list to change them.

As a URL, for code and most toolshttp://USERNAME:PASSWORD@HOST:PORTsocks5://USERNAME:PASSWORD@HOST:PORT

Use http:// even for HTTPS websites; the TLS session still runs end to end. The socks5:// form is for static ISP and ISP subnet proxies.

How to set up CleanProxies in Rust reqwest

Four steps, then check the exit IP with the free proxy checker.

  1. 1

    Add the dependencies

    Add reqwest (with socks if needed) and Tokio to Cargo.toml.

  2. 2

    Create the proxy

    Call Proxy::all("http://HOST:PORT")? and chain .basic_auth("USERNAME", "PASSWORD").

  3. 3

    Build the client

    Pass it to Client::builder().proxy(...), set a timeout and call .build()?.

  4. 4

    Run it

    Run cargo run; the program prints the exit IP from https://api.ipify.org.

copy & paste

Rust reqwest proxy examples

Replace the highlighted placeholders with the values from your dashboard. Pick an example to see its code.

Rust reqwest + CleanProxies

reqwest proxy example

Cargo.tomlText
[dependencies]
reqwest = { version = "0.13", features = ["socks"] } # "socks" only for SOCKS5
tokio = { version = "1", features = ["full"] }
  • Proxy::all covers http:// and https:// URLs; Proxy::http and Proxy::https cover one scheme each. Adding a proxy turns off reqwest's system proxy, which otherwise reads HTTP_PROXY, HTTPS_PROXY and ALL_PROXY by default; .no_proxy() turns all proxies off.
fix it fast

Troubleshooting Rust reqwest proxy errors

Verify your exit IP

cargo run prints the exit IP. Comment out .proxy(proxy) and run it again to compare with your own address; if both match, the proxy isn't being applied.

Open What is my IP? through the proxy to see the address and headers a website receives, or paste up to ten lines into the free proxy checker to test connectivity, latency and exit IP.

Still stuck? Our 24/7 support team answers fast: contact us with the error and the line you used (leave the password out).

Rust reqwest error fixes
  • 407 or a proxy authentication error on sendWhy: Wrong credentials, or special characters in a password embedded in the proxy URL.Pass the credentials with .basic_auth() instead of the URL.
  • HTTPS requests go out directlyWhy: The proxy was added with Proxy::http, which only covers http:// URLs.Use Proxy::all (or add a Proxy::https as well).
  • SOCKS5 requests fail to connectWhy: The socks feature isn't enabled, or SOCKS5 isn't switched on for that ISP list.Add features = ["socks"] to reqwest and enable SOCKS5 for the list in your dashboard.
  • The same IP on every request with a rotating lineWhy: The client reuses pooled keep-alive connections.Build the client with .pool_max_idle_per_host(0).

Rust reqwest proxy guides

Setup guides and best practices from the CleanProxies blog.

Get the latest insightsAll Blogs

More integrations

Setup guides for tools people run next to Rust reqwest.

Proxies for sites people reach with Rust reqwest
All integrations

Rust reqwest proxy FAQs

Straight answers about running CleanProxies in Rust reqwest.

Chain basic_auth(username, password) on the Proxy, or put the credentials in the proxy URL. Both send the username and password to the proxy; basic_auth avoids URL-encoding problems.

Got more questions?All FAQs