curl proxy setup with authentication and rotation

You can use RotatingProxy with curl by passing the proxy details via the -x (or --proxy) flag and authentication with -U (or --proxy-user). The gateway host is gw.rotatingproxy.cc, using port 7070 for HTTP/HTTPS and port 7071 for SOCKS5. This guide covers the exact syntax for targeting countries, cities, and managing sessions, plus troubleshooting common errors.

Key points
  • Use -x http://gw.rotatingproxy.cc:7070 and -U USERNAME:PASSWORD for HTTP proxy.
  • For SOCKS5, use -x socks5h://gw.rotatingproxy.cc:7071 and the same -U flag.
  • Target locations and set sessions by adding options like _cc.us_city.chicago to the username.
  • Verify your exit IP with curl -x ... https://api.ipify.org to confirm rotation.

curl proxy settings: -x and -U flags

The proxy configuration in curl is passed as a command-line argument, not stored in a config file. The primary flag is -x (or its long form --proxy) to set the proxy address, and -U (or --proxy-user) to provide the username and password for proxy authentication. This makes it easy to integrate into scripts and one-off commands for tasks like web scraping or price monitoring.

For RotatingProxy, the gateway address is always gw.rotatingproxy.cc. You have two port choices: 7070 for HTTP/HTTPS (CONNECT) proxy, and 7071 for SOCKS5 proxy. The username is a composite string that includes your proxy user login and any targeting or session options, separated by underscores. The password is the one you created for that proxy user in the dashboard. A basic command looks like this:

curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME:PASSWORD" https://httpbin.org/ip

This command routes the request through the proxy and returns the IP address the target site sees, which should be a rotating residential IP by default.

HTTP and HTTPS proxy on port 7070

Port 7070 is an HTTP proxy that supports the CONNECT method for HTTPS tunnels. When you use http:// as the proxy scheme with port 7070, curl will send HTTP requests directly to the proxy and use CONNECT for HTTPS URLs. This is the standard method for secure browsing through a proxy and works with virtually all websites.

Here is the exact syntax for an HTTPS request through the HTTP proxy port:

curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME_net.res_cc.us:PASSWORD" https://example.com

In this example, the username includes the network option net.res for rotating residential IPs and the country code cc.us for United States exits. You can combine multiple options. For instance, to target Chicago with a sticky session for 30 minutes, you would use:

curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME_net.res_cc.us_city.chicago_sid.abc123_ttl.30:PASSWORD" https://example.com

The proxy handles the TLS handshake with the target site after the CONNECT tunnel is established. Your traffic is charged from your pay-as-you-go balance based on the total bytes transferred.

SOCKS5 proxy on port 7071 with socks5h

Port 7071 is a SOCKS5 proxy. The key difference from HTTP proxy is that SOCKS5 operates at a lower level, handling any TCP traffic. For curl to correctly resolve domain names through the proxy (preventing DNS leaks), you must use the socks5h:// scheme, not socks5://. The 'h' stands for hostname, meaning curl will send the hostname to the proxy for resolution.

The correct command for SOCKS5 is:

curl -x socks5h://gw.rotatingproxy.cc:7071 -U "USERNAME:PASSWORD" https://example.com

All the same username options for network, country, city, and sessions apply. For example, to use rotating mobile proxies in Germany with a session:

curl -x socks5h://gw.rotatingproxy.cc:7071 -U "USERNAME_net.mob_cc.de_sid.myappk_ttl.60:PASSWORD" https://api.ipify.org

If your tool or library does not support SOCKS5 with authentication, you can use the HTTP proxy port 7070 instead. For a full comparison, see HTTP port vs SOCKS5 port on our gateway.

Passing geo-targeting and session options in the username

You control the proxy network, exit location, and session behavior by appending key.value pairs to your proxy user login, separated by underscores. The full grammar is: LOGIN_net.{res|mob|dc|isp}_cc.XX_st.YY_city.token_sid.abc123_ttl.N.

For example, to use rotating ISP proxies (net.isp) exiting in France, the username becomes USERNAME_net.isp_cc.fr. To target a specific US state like California, add st.ca (only works with cc.us). City targeting uses a predefined token; for New York City, it's city.new-york. You can find the list of available cities in the dashboard's proxy builder tool.

To maintain the same IP across multiple requests (a sticky session), include a sid (session ID) and optionally a ttl (time-to-live in minutes, default 10). The session ID can be any 6 to 16 character string of lowercase letters and digits. This is useful for social media management or tasks that require a consistent IP. Without a sid, each new connection gets a fresh IP from the chosen location.

# Rotating IP (new IP each call)
curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME_net.res_cc.gb:PASSWORD" https://httpbin.org/ip

# Sticky session for 45 minutes
curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME_net.res_cc.gb_sid.test45_ttl.45:PASSWORD" https://httpbin.org/ip

Verifying the exit IP and location

After setting up your curl proxy command, you should verify that the proxy is working and that the exit IP matches your targeting. Simple public endpoints like https://api.ipify.org (returns just the IP) or https://ipinfo.io/json (returns IP details in JSON) are perfect for this.

Run a test with your full username options:

curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME_net.mob_cc.jp:PASSWORD" https://ipinfo.io/json

You should see a JSON response with an IP address located in Japan. If you requested a mobile network (net.mob), the IP's ASN will typically belong to a mobile carrier. This verification step is crucial when setting up proxies for checking geo-restricted content or rank tracking in different regions.

If the IP is not from the expected country, double-check the country code (lowercase ISO 3166-1 alpha-2) and ensure your proxy user is allowed to use the selected network. You can also check your account's usage details to confirm traffic is being recorded.

Common curl proxy errors and fixes

When using curl with a proxy, you may encounter a few specific errors.

Proxy Authentication Required (407): This means the proxy rejected your credentials. Ensure the username string is correctly formatted with underscores, the password is correct, and the entire USERNAME:OPTIONS:PASSWORD string is placed within quotes if it contains special characters. Also, confirm the proxy user is not paused or over its monthly GB cap. See our dedicated page on proxy error 407.

Connection timeouts: If curl hangs and times out, it could be due to network blocking, a saturated proxy gateway, or an issue with the target site. First, test with a simple IP check to see if basic connectivity works. If that fails, try a different network (e.g., switch from net.res to net.dc). Ensure you are not exceeding the concurrent connection limit of 1,000 per account. Introduce retries with exponential backoff in your scripts.

TLS/SSL errors: Errors like "SSL certificate problem" or "Failed to connect" may occur if the proxy's CONNECT tunnel is interrupted. Using the HTTP proxy port (7070) for HTTPS is standard and should work. If you encounter persistent TLS issues, add the -v (verbose) flag to inspect the handshake. Sometimes, using SOCKS5h (port 7071) can bypass certain TLS interception issues, as it tunnels TCP directly.

Debugging with verbose output and trace files

curl's -v (verbose) flag is invaluable for debugging proxy connections. It shows the detailed HTTP conversation, including the CONNECT request, proxy authentication headers, and the subsequent request to the target.

curl -v -x http://gw.rotatingproxy.cc:7070 -U "USERNAME:PASSWORD" https://httpbin.org/ip 2>&1 | head -20

Look for lines like "CONNECT httpbin.org:443 HTTP/1.1", "Proxy-Authorization: Basic ...", and the final "HTTP/1.1 200 OK". If authentication fails, you'll see "HTTP/1.1 407 Proxy Authentication Required". For even more detail, use --trace-ascii debug.log to write everything to a file. This can help diagnose issues with TLS through a proxy or header manipulation.

When working at scale, avoid leaving verbose logging enabled in production as it adds overhead. Use it only during initial setup or when troubleshooting a specific failing request.

Tips for running curl with proxies at scale

When making many requests, you need to manage efficiency, concurrency, and cost. Here are practical tips.

Use connection reuse (HTTP keep-alive): curl can reuse connections to the same proxy for multiple requests, reducing latency. Use the --keepalive-time option and consider grouping requests to the same target host. Note that each unique combination of username options (like a different session ID) may establish a new proxy connection.

Manage concurrency with xargs or parallel: To run multiple curl processes in parallel, use shell tools. For example, to fetch 10 URLs with up to 5 concurrent connections using the same proxy settings:

cat urls.txt | xargs -P5 -I{} curl -x http://gw.rotatingproxy.cc:7070 -U "USERNAME:PASSWORD" -s {} > /dev/null

Monitor your account's concurrent connection count in the dashboard to stay under the limit.

Implement retries and backoff: Network requests through proxies can fail intermittently. Wrap your curl commands in a script that retries on non-2xx status codes or timeouts, with increasing delays. This is a core part of retry strategies for proxy requests.

Minimize traffic to control costs: Since billing is per GB, compress responses when possible (curl supports --compressed), cache unchanged content locally, and only download necessary data. For large-scale projects like AI training data collection, estimate your bandwidth with our traffic calculator.

Rotate sessions appropriately: For stateless scraping, omit the sid to get a new IP each connection. For stateful interactions (like maintaining a shopping cart), use a sid with a sufficient ttl. Remember that a session IP may change if the underlying device goes offline; plan for this in your application logic.

Integrating into scripts and automation

For production use, you'll likely embed curl commands in bash scripts, Python subprocesses, or cron jobs. Store your proxy credentials securely, not in plain text within scripts. Use environment variables or a configuration file with restricted permissions.

Example bash script using environment variables:

#!/bin/bash
PROXY="http://gw.rotatingproxy.cc:7070"
CREDS="${PROXY_USER}:${PROXY_PASS}"
curl -x "$PROXY" -U "$CREDS" "https://api.ipify.org"

For more advanced automation, consider using a dedicated HTTP client library in Python, Node.js, or Go, which offer better connection pooling and error handling. Check our integration guides for Python requests proxy, axios proxy, and Go HTTP proxy.

Next steps and other integrations

Once you have curl working, you can apply the same proxy settings to other command-line tools like wget or to configure system-wide proxy settings for macOS or Linux. For browser-based automation, see our guides for Playwright Python proxy and Selenium proxy with authentication.

Always refer to the username options documentation for the latest syntax, and monitor your balance and usage in the dashboard. If you run into issues, our support tickets are answered by engineers.

Questions

Can I use curl with RotatingProxy for scraping Google Search?

Yes, you can target Google Search by using appropriate geo-targeting options in the username, such as `cc.us` for United States results. Be sure to respect Google's robots.txt and rate limits to avoid blocks. For dedicated guidance, see our page on Google search proxies.

Why does my curl command work for HTTP sites but fail for HTTPS?

This usually indicates an issue with the HTTP CONNECT tunnel. Ensure you are using port 7070 (HTTP proxy) with the `http://` scheme in the `-x` flag. The proxy handles HTTPS via CONNECT automatically. Adding the `-v` flag will show if the CONNECT request is being sent and authenticated.

How do I make curl use a different IP for each request automatically?

Omit the `sid` (session ID) option from your username. For example, use `USERNAME_net.res_cc.fr` without any `sid.` parameter. Each new TCP connection (or reused connection after keep-alive expires) will then receive a different IP from the chosen location and network.

What is the difference between using port 7070 and port 7071 in terms of performance?

Both ports offer similar performance for HTTP/HTTPS traffic. Port 7071 (SOCKS5) may have slightly lower overhead for pure TCP streaming, but for web requests the difference is negligible. Choose based on your client's support; curl works well with both. The key is to use `socks5h://` for SOCKS5 to avoid DNS leaks.

Can I set the proxy for curl globally so I don't have to type -x every time?

curl does not have a built-in global proxy configuration file, but you can set the `http_proxy`, `https_proxy`, and `all_proxy` environment variables. For example, `export http_proxy=http://USERNAME:PASSWORD@gw.rotatingproxy.cc:7070`. However, this method does not easily support the complex username options (like `_cc.us`). For advanced targeting, it's better to use the `-x` flag in scripts.

How can I check how much traffic my curl commands have used?

Sign in to your RotatingProxy dashboard and go to the Usage area. It shows traffic per day and per network (residential, mobile, etc.). You can also use the REST API with an API key to programmatically fetch usage data. Traffic is measured as upload plus download bytes through the gateway, rounded to the nearest GB.

Start with one top-up, use any network

Create an account in a minute, add $40 or more, and the same balance pays for residential, mobile, datacenter and ISP traffic.