Using wget with a proxy confuses people coming from curl, because wget has no single proxy flag. It reads the proxy from environment variables or from its config file, and you pass credentials separately. Once you know where it looks, it's simple, and wget's recursive downloads and resume support make it handy for fetching large files through a proxy.
Quick Test with Environment Variables
export https_proxy='http://global.nodeproxies.xyz:8080'
export http_proxy="$https_proxy"
wget -qO- --proxy-user='USERNAME-country-us' --proxy-password='PASSWORD' https://api.ipify.org; echo-qO- prints the response to the terminal instead of saving a file. The output should be the proxy's IP. Note that https_proxy points at an http:// URL: the proxy itself speaks HTTP and tunnels HTTPS through it.
One-Off Proxy with -e
To use a proxy for a single command without touching the environment, pass wgetrc settings with -e:
wget -e use_proxy=yes \
-e https_proxy=http://global.nodeproxies.xyz:8080 \
-e http_proxy=http://global.nodeproxies.xyz:8080 \
--proxy-user='USERNAME' --proxy-password='PASSWORD' \
https://example.com/file.zipYou can also put credentials in the proxy URL (http://USERNAME:[email protected]:8080), but --proxy-user and --proxy-password avoid URL-encoding problems with special characters.
Permanent Setup in .wgetrc
For a machine that should always use the proxy, add these lines to ~/.wgetrc (per user) or /etc/wgetrc (system-wide):
use_proxy = on
http_proxy = http://global.nodeproxies.xyz:8080
https_proxy = http://global.nodeproxies.xyz:8080
proxy_user = USERNAME
proxy_password = PASSWORD
no_proxy = localhost,127.0.0.1Restrict the file's permissions with chmod 600 ~/.wgetrc since it contains your password. To bypass it for one command, add --no-proxy.
wget and SOCKS5
wget doesn't support SOCKS proxies. If you need SOCKS5, use curl with socks5h:// instead (see the curl proxy guide), or use the HTTP endpoint on port 8080, which handles the same traffic for downloads.
Large Downloads: Use a Sticky Session
With a rotating proxy, a resumed download may come from a different IP than the first part. Most file servers don't mind, but some download links are signed to the IP that requested them. A sticky session keeps the IP stable for the whole transfer:
wget -c --tries=5 --timeout=30 \
--proxy-user='USERNAME-country-us-session-dl1-time-60' --proxy-password='PASSWORD' \
https://example.com/big-dataset.tar.gz-c resumes a partial file, --tries retries on failure and --timeout stops hanging on a stalled connection. Remember bandwidth is billed per GB: a 5 GB file costs 5 GB of plan, so check sizes first with wget --spider.
Mirroring Through a Proxy, Politely
wget's recursive mode can fetch a whole site. Through a proxy, the same manners apply as without one:
wget --mirror --no-parent --wait=2 --random-wait --limit-rate=500k \
-e robots=on \
--proxy-user='USERNAME-country-us-session-mirror1-time-120' --proxy-password='PASSWORD' \
https://example.com/docs/robots=on is the default, but stating it makes the intent clear. --wait and --random-wait space out requests, and --limit-rate keeps you from saturating the server. Read are proxies legal before mirroring content you don't own, and how to avoid blocks when web scraping for pacing.
Reading wget Proxy Errors
- "Proxy tunneling failed: Proxy Authentication Required": wrong credentials or inactive plan (407). Check --proxy-user.
- "Proxy tunneling failed: Payment Required": your plan is out of bandwidth (402).
- "Connecting to global.nodeproxies.xyz ... failed: Connection refused": wrong port, or a firewall.
- "Proxy tunneling failed: Bad Gateway": the proxy couldn't reach the target. Retry.
A New IP per File in a Script
To spread a batch of downloads across IPs while keeping each file on one IP, give each file its own session id:
#!/bin/sh
for i in 1 2 3 4 5; do
wget -q -c \
--proxy-user="USERNAME-country-us-session-file$i-time-10" \
--proxy-password='PASSWORD' \
-O "page$i.html" "https://example.com/page/$i"
sleep 2
doneThe sleep keeps the request rate polite. Replace the URL list with a file and a while read loop for larger batches.
Seeing What wget Sends to the Proxy
When something fails and the error message is vague, run wget with -d (debug). It prints the CONNECT request sent to the proxy and the proxy's response line, so you can see the exact status, such as 407 or 502, and confirm the Proxy-Authorization header is being sent. Debug output includes your credentials encoded in that header, so don't paste it into public forums. If -d prints nothing extra, your wget build was compiled without debug support; -S still shows the server's response headers.
Check the Size Before You Spend the Bandwidth
Run wget --spider -S with the same proxy options before a large download. It sends a request without saving the body and prints the server's headers, including Content-Length. Divide by a billion for an approximate GB figure and you know what the download will cost on a per-GB plan before you start it. Some servers don't send a length for dynamic content, in which case you'll only find out by downloading.
Using wget with NodeProxies
Set http_proxy and https_proxy to http://global.nodeproxies.xyz:8080 and pass your dashboard credentials. For bulk downloads where IP type doesn't matter, datacenter proxies are the cheapest per GB. Create an account and buy from 100 MB on the pricing page.
FAQ
How do I pass a proxy username and password to wget?
Use --proxy-user and --proxy-password, or set proxy_user and proxy_password in .wgetrc.
Does wget support SOCKS5 proxies?
No. wget only supports HTTP proxies. Use curl for SOCKS5.
How do I make wget ignore the proxy?
Add --no-proxy to the command, or set use_proxy = off in .wgetrc.
