How to Use a Rotating Proxy with wget
You can configure wget to use RotatingProxy's gateway through environment variables or a wgetrc configuration file. This guide covers HTTP and SOCKS5 setup, passing location and session options in the username, and verifying your exit IP.
- Set the proxy via http_proxy/https_proxy environment variables or the wgetrc file.
- Use port 7070 for HTTP/HTTPS and 7071 for SOCKS5 with authentication.
- Embed targeting and session options directly in the proxy username.
- Verify the exit IP with a simple wget command to ipify.org.
wget proxy configuration methods
wget can be directed to use a proxy server through two primary methods: environment variables and a configuration file. The environment variables http_proxy, https_proxy, and ftp_proxy are read by wget on startup. Alternatively, you can set these options permanently in a wgetrc file, which is useful for scripts and automated tasks. For RotatingProxy, you will use the gateway host gw.rotatingproxy.cc and either port 7070 for HTTP/HTTPS proxy or port 7071 for SOCKS5 proxy. Authentication credentials are passed in the standard username:password@host:port format. This configuration is useful for web scraping or price monitoring where you must send requests from various places.
Setting proxy environment variables for wget
Export the http_proxy and https_proxy environment variables in your shell session before running wget. The variable value must include the protocol (http:// or https://), the proxy credentials, host, and port. For RotatingProxy's HTTP proxy port, use the following format, replacing USERNAME and PASSWORD with your proxy user's login and password:
export http_proxy="http://USERNAME:PASSWORD@gw.rotatingproxy.cc:7070"
export https_proxy="http://USERNAME:PASSWORD@gw.rotatingproxy.cc:7070"
After setting these variables, any wget command will automatically use the proxy. Note that the protocol for the https_proxy variable is still http:// because it refers to the proxy protocol, not the target site's protocol. This method is session-specific; closing the terminal will clear the variables. For persistent setup, consider adding these lines to your shell profile (e.g., .bashrc, .zshrc). This approach is common when building tools for rank tracking or market research.
Configuring wgetrc for permanent proxy settings
To make wget always use the proxy without environment variables, edit the global /etc/wgetrc or user-specific ~/.wgetrc file. Add the following lines, again substituting your actual credentials:
use_proxy = on
http_proxy = http://USERNAME:PASSWORD@gw.rotatingproxy.cc:7070
https_proxy = http://USERNAME:PASSWORD@gw.rotatingproxy.cc:7070
The use_proxy = on directive is required to activate the proxy settings. Ensure there is no leading # (comment symbol) on these lines. After saving the file, the settings apply to all future wget invocations. This is ideal for automated systems and servers where you need consistent proxy routing for website monitoring or data journalism projects. If you need to temporarily bypass the proxy for a single command, use the --no-proxy option.
Using SOCKS5 proxy with wget on port 7071
wget has built-in support for SOCKS5 proxies. To use RotatingProxy's SOCKS5 gateway on port 7071, you must set the environment variables or wgetrc entries with a socks5:// scheme. The format is slightly different:
export http_proxy="socks5://USERNAME:PASSWORD@gw.rotatingproxy.cc:7071"
export https_proxy="socks5://USERNAME:PASSWORD@gw.rotatingproxy.cc:7071"
In your wgetrc file, you would set:
http_proxy = socks5://USERNAME:PASSWORD@gw.rotatingproxy.cc:7071
https_proxy = socks5://USERNAME:PASSWORD@gw.rotatingproxy.cc:7071
Using SOCKS5 can be beneficial as it handles both HTTP and HTTPS traffic uniformly at the socket level. Note that wget does not natively support SOCKS4; the socks5:// scheme is required. This setup is useful when your toolchain or target sites work better with SOCKS, such as in some social media management tasks.
Adding geo targeting and sessions to the wget proxy username
RotatingProxy uses a flexible username grammar where you append options with underscores. Your proxy username becomes a string like login_net.res_cc.us_st.ca_city.san-francisco_sid.abc123_ttl.30. In wget, you include this full string as the username part of the proxy URL. For example, to target German residential IPs with a sticky session:
export http_proxy="http://zq4k8m2tva_net.res_cc.de_city.berlin_sid.a7k2m9_ttl.20:PASSWORD@gw.rotatingproxy.cc:7070"
The options are: net.res (residential network), cc.de (country Germany), city.berlin, sid.a7k2m9 (session ID), and ttl.20 (20-minute session lifetime). Without a sid, you get a new IP on each connection. For detailed syntax, refer to username options. This targeting is crucial for checking geo-restricted content or localization testing. Remember, city targeting is available for residential and mobile networks; for datacenter and ISP proxies, only country targeting works.
Testing and verifying your wget proxy connection
After configuration, verify that wget is using the proxy and that the exit IP matches your targeting. A simple test is to fetch a page that returns your public IP. Use the following command:
wget -qO- https://api.ipify.org
This should output the IP address assigned by RotatingProxy. To see more details like location, you can use:
wget -qO- https://ipinfo.io/json
The response will be a JSON block showing country, region, city, and ISP. Confirm that the location matches your cc and city options. This verification step is a best practice before starting any large data collection job, such as financial data collection or real estate data aggregation. If you see your local IP, the proxy is not being used; check your environment variables or wgetrc file.
Fixing common wget proxy errors: 407, timeouts, TLS
A 407 "Proxy Authentication Required" error means wget did not provide valid credentials. Double-check the username and password for typos, and ensure the full option string is in the username field, not the password. Also verify that the proxy URL uses the correct protocol (http:// for port 7070, socks5:// for port 7071). Timeouts can occur if the proxy gateway is unreachable due to network issues, or if your balance has run out (see what happens when the balance runs out). Increase wget's timeout settings with --timeout=60 and --tries=3. For TLS/SSL errors when using the HTTP proxy on port 7070, ensure you are using the https_proxy variable correctly. Some older wget builds may have issues with certain TLS versions through proxies; updating wget usually helps. For more on TLS, read TLS through a proxy.
Running wget at scale with rotating proxies
For large-scale downloading, manage concurrency and sessions carefully. RotatingProxy allows up to 1,000 concurrent connections per account. To avoid overwhelming a single target site, use wget's --wait and --random-wait options to space out requests. Implement a retry strategy for failed downloads using --tries and --retry-connrefused. If you need to maintain sessions (like staying logged in), use the sid and ttl options in the username. For rotating IPs on every request, omit the sid. To distribute traffic across different locations, create multiple proxy users with different targeting and use separate environment variables for different shell sessions or scripts. Monitor your traffic usage in the dashboard to stay within budget; our volume rates automatically lower the per-GB cost as you use more within a month. For planning, see our guide on planning concurrency for crawlers.
wget proxy examples for different use cases
Here are concrete examples for common scenarios. To download a page using a mobile proxy in France:
http_proxy="http://USERNAME_net.mob_cc.fr:PASSWORD@gw.rotatingproxy.cc:7070" wget https://example.com
To use a datacenter proxy in Japan with SOCKS5:
export http_proxy="socks5://USERNAME_net.dc_cc.jp:PASSWORD@gw.rotatingproxy.cc:7071"
wget https://example.com
To scrape a site with a sticky session in Chicago, saving cookies:
export http_proxy="http://USERNAME_net.res_cc.us_st.il_city.chicago_sid.myid123_ttl.60:PASSWORD@gw.rotatingproxy.cc:7070"
wget --save-cookies cookies.txt https://example.com/login
These patterns can be adapted for Google search, Amazon, or LinkedIn data collection. Always respect the target site's robots.txt and rate limits; our web scraping best practices offer guidance.
Advanced wgetrc options for proxy tuning
Beyond basic proxy settings, wgetrc offers options to fine-tune proxy behavior. You can set a different proxy for FTP traffic with ftp_proxy. The waitretry setting controls how long to wait between retries. To handle sites that block requests without a User-Agent, set it explicitly:
user_agent = Mozilla/5.0 (compatible; wget; +http://yourdomain.com)
You can also disable proxy use for certain domains with no_proxy:
no_proxy = localhost,127.0.0.1,*.internal.company
Check the current wget documentation for all available options, as details can change between versions. These tweaks help in complex environments like performance testing by region or security research.
Switching between proxy configurations quickly
If you need to switch between different proxy users or networks often, create shell aliases or functions. For example, add to your .bashrc:
alias wget-res="http_proxy='http://USERNAME_net.res:PASSWORD@gw.rotatingproxy.cc:7070' wget"
alias wget-mob="http_proxy='http://USERNAME_net.mob:PASSWORD@gw.rotatingproxy.cc:7070' wget"
Then run wget-res https://example.com. For more dynamic switching, write a wrapper script that constructs the proxy URL based on arguments. This is efficient when working on multiple projects, such as review monitoring across different countries or lead generation research. Remember, you can create up to 25 proxy users per account, each with its own network permissions and optional monthly GB cap (see setting a monthly GB cap).
Questions
Can I use wget with a proxy that requires authentication?
Yes, wget supports proxy authentication via the username:password@host format in the http_proxy environment variable or wgetrc file. Include your full RotatingProxy username with any targeting options.
Does wget work with SOCKS5 proxies?
Yes, wget supports SOCKS5 proxies. Use the socks5:// scheme in your http_proxy and https_proxy settings, pointing to port 7071 on our gateway.
How do I make wget use a different proxy for a single command?
Prefix the wget command with the variable assignment, like http_proxy="http://..." wget URL. This overrides any environment or wgetrc settings for that command.
Why is wget ignoring my proxy settings?
Check that use_proxy = on is set in wgetrc, or that the environment variables are exported correctly. Also, ensure there are no typos in the proxy URL. Verify with echo $http_proxy.
Can I use wget to download files through a proxy with a sticky session?
Absolutely. Include the session ID (sid) and time-to-live (ttl) options in the username part of your proxy URL. All connections from that wget process will use the same IP for the session duration.
How do I see what IP address wget is using when going through the proxy?
Run wget -qO- https://api.ipify.org. The output will be the exit IP provided by RotatingProxy, confirming your proxy and targeting are working.
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.