wget Proxy Setup: Flags, Config Files, Authentication and SOCKS5 Workarounds
wget can route its downloads through an HTTP, HTTPS or FTP proxy, and the setup is a few lines of configuration once you know which layer wins. This guide walks through the four placement options, the precedence order between them, how to authenticate safely, how to exclude internal hosts, and the practical workaround for SOCKS5, which wget does not speak natively.
What wget can and cannot proxy
wget handles HTTP, HTTPS and FTP proxies through the matching environment variables (http_proxy, https_proxy, ftp_proxy). It does not speak SOCKS natively, so a socks5:// URL in a config file will not work. For SOCKS you need a wrapper such as proxychains4 or torsocks, or a different client. cURL supports SOCKS4, SOCKS5, NTLM proxy authentication and HTTPS-to-proxy connections without wrappers, so it is the better fit when SOCKS is a regular requirement.
Proxy authentication is limited to Basic. If a corporate proxy demands NTLM or Kerberos, wget will keep returning 407 no matter what credentials you supply; curl or a local authentication bridge is the answer there.
A short version: HTTP, HTTPS, FTP — yes. SOCKS5 — no. Basic auth — yes. NTLM/Kerberos — no.
Install wget before configuring anything
Proxy settings only take effect if wget is installed and on your PATH. Most Linux distributions ship it; macOS and Windows usually need a manual install.
- Debian/Ubuntu: see the install command module for the apt invocation.
- RHEL/CentOS/Fedora: see the install command module for the dnf invocation (use yum on older systems).
- macOS: see the install command module for the Homebrew invocation.
- Windows: grab a prebuilt binary from the GNU project or use the Chocolatey command module.
Confirm the install with the version-check command module before touching proxy settings.
Which layer wins: precedence order
If you set a proxy in more than one place, wget resolves them in this order, highest first:
- Command-line options (-e use_proxy=yes -e http_proxy=...).
- ~/.wgetrc (per user).
- /etc/wgetrc (system-wide).
- Environment variables (http_proxy, https_proxy, ftp_proxy, no_proxy).
That order explains most 'my proxy is ignored' surprises: a leftover environment variable can silently override what you thought you configured, and a flag can override a config file you forgot about. When a request goes direct instead of through the proxy, check the higher layers first.
Method 1: one-off command flags
For a single download, pass the proxy inline. Nothing is written to disk, so this is the safest option for ad-hoc use and the fastest way to confirm a proxy works before committing it to a config file.
The unauthenticated form is the one-line flag command in the command module. The authenticated form adds --proxy-user and --proxy-password, as shown in the authenticated flag module.
To verify the proxy is actually active, print your exit IP with the ipify check module. If the returned address differs from your real one, traffic is tunnelling through the proxy.
Method 2: per-user ~/.wgetrc
A user config applies to your account only and persists across sessions. On Linux and macOS the file is ~/.wgetrc. On Windows, try C:/Users/<USERNAME>\.wgetrc or C:/Users/<USERNAME>/_wgetrc; the exact name depends on your build.
The example config module shows the full set of keys: use_proxy, http_proxy, https_proxy, proxy_user, proxy_password and no_proxy. After saving, every wget call uses the proxy unless a flag overrides it.
Caveat: the file is plain text. Anyone with access to your account can read the credentials inside, so treat it like any other secrets file.
Method 3: system-wide /etc/wgetrc
For a fleet, container base image or shared server, put the proxy in /etc/wgetrc so every user and job inherits it. Editing the file needs root. The system config module shows the minimal keys.
On Unix-like systems the path is /etc/wgetrc. On Windows the location depends on the build and is often alongside the wget executable. Avoid storing passwords in the system file unless you have a deliberate reason; per-user config or environment injection is usually cleaner.
Method 4: environment variables
Environment variables suit scripts, containers and temporary sessions. Set http_proxy and https_proxy (and ftp_proxy if needed) once and wget picks them up on every request. The Linux/macOS export module and the Windows CMD set module show the syntax.
For most proxies, both http_proxy and https_proxy use the http:// scheme. Even when the destination is HTTPS, wget first connects to the proxy over HTTP and then opens a secure tunnel with the HTTP CONNECT method. If your provider offers a true HTTPS proxy endpoint, you can use https://HOST:PORT instead.
To stop using the proxy, unset the variables with the unset module on Linux/macOS or the clear module on Windows.
Authenticated proxies: three placements, one limitation
You can pass credentials with flags, store them in ~/.wgetrc, or embed them in the proxy URL as http://USER:PASS@HOST:PORT. All three work; the choice is about persistence and exposure.
- Flags: safest for ad-hoc use because the password is not written to disk.
- ~/.wgetrc: convenient for day-to-day work, but plain text on disk.
- CI: inject via environment variables at runtime rather than baking a config into an image.
If a password contains @, :, &, $ or spaces, quote it. Some shells also need escaping for &, $ and @; Windows CMD rules differ but quoting is usually enough. The escaped-password module shows the pattern.
Remember the Basic-only limit: NTLM or Kerberos proxies will keep returning 407 regardless of the credentials you supply.
SOCKS5: the proxychains4 workaround
wget does not understand SOCKS, so socks_proxy or a socks5:// URL in a config file will not help. The practical workaround is proxychains4, a wrapper that sits between wget and the network: it hooks a program's socket calls at the operating-system level and forwards them to a SOCKS proxy, so wget itself never needs to know SOCKS exists.
Add your proxy to the [ProxyList] section of the proxychains4 config. The unauthenticated entry module and the authenticated entry module show the two forms. Then run wget through the wrapper with the proxychains4 invocation module. Any wget flag still works, for example the retries example module.
For Tor specifically, use torsocks instead; it is designed for Tor's SOCKS proxy and works out of the box, as shown in the torsocks module.
Rate limiting, retries and no_proxy
Three flags keep proxy traffic predictable.
- --limit-rate caps download speed. The limit-rate module shows the syntax; k and m units are accepted (200k, 2m).
- --tries and --waitretry control retries and the delay between failed attempts. The retries module shows the combination. Retries only kick in on connection timeouts, DNS hiccups, dropped connections or certain HTTP errors such as 5xx and rate limiting; a clean first download never waits. A permanent problem (wrong URL, hard block, real 404) will burn the retry budget and then give up.
- no_proxy excludes hosts from the proxy. Separate entries with commas and no spaces, as in the no_proxy module. A leading dot such as .internal.local matches any host ending in internal.local. For a single download, the --no-proxy flag skips the proxy entirely, as shown in the no-proxy module. You can combine a proxy with no_proxy as in the combined module.
Rotating proxies: the shell loop and its limits
The simplest DIY rotation is a plain text list of proxies plus a small shell loop. Put one proxy per line in proxies.txt (the list module shows the format), then pick a random line with shuf before each request, as in the shuf module. To loop over multiple URLs, use the loop module; the Windows CMD equivalents are in the CMD single module and the CMD loop module.
This works for quick experiments, but a rotating free or scraped list has predictable problems: most free proxies die within hours, public proxies are overused and often already blocked, per-proxy credentials become a maintenance headache, and you end up babysitting the list instead of doing the actual work.
For real scraping, backups or site mirroring, a managed provider handles automatic IP rotation, residential or premium pools, geolocation targeting, ban handling and retries, and consistent uptime. DIY is fine for testing; production usually wants managed rotation.
Choosing the right approach
Match the method to the task instead of stacking configs.
- One-off test: command flags. Fast, clean, nothing saved on disk.
- Regular local use or CI pipelines: ~/.wgetrc. Consistent per-user behaviour, no repeated flags, clean scripts.
- Fleet, containers or shared servers: /etc/wgetrc for machine-wide defaults, or environment-based settings in containers (often easier than baking configs into images).
- Rotation, geolocation or JS rendering: a managed endpoint in API or proxy mode, so you are not juggling dead proxies or writing rotation logic.
Short version: flags for quick checks, ~/.wgetrc for personal or CI use, /etc/wgetrc for shared systems, managed endpoints when you need real proxy features without DIY infrastructure.
Troubleshooting: distinguishing the common failures
The error text usually points at the layer that failed.
- Proxy not used (request goes direct): confirm use_proxy = on if you are using a wgetrc file, check for typos in http_proxy and https_proxy, ensure no_proxy entries are comma-separated without spaces, and look for leftover environment variables that may be silently overriding your config.
- 407 Proxy Authentication Required (or 'Proxy tunneling failed: Proxy Authentication Required'): verify the username and password. If they are correct and the error persists, the proxy likely needs NTLM or Kerberos, which wget's Basic-only support cannot satisfy; switch to curl or a local authentication bridge.
- 400 Bad Request: usually a wrong host or port, a malformed proxy URL, or leftover http_proxy/https_proxy environment variables. Clear them and retry.
- SSL errors: check that CA certificates are current and that you are using the correct proxy endpoint. Avoid --no-check-certificate except in testing; it disables certificate validation.
BusyBox wget (Alpine, Docker)
BusyBox wget can route through http_proxy and https_proxy, but it is a reduced build: the --proxy-user and -e options that GNU wget provides are absent. When the proxy requires credentials, embed them in the URL itself (http://USER:PASS@HOST:PORT). If you need the complete option set, install GNU wget in Alpine with apk add wget.
Frequently asked questions
How do I use a proxy with wget for a single command?
Use the -e use_proxy=yes flag and point http_proxy at your server. This is the fastest way to run wget through a proxy once without changing your system config. The command module shows the exact form.
How can I set an authenticated proxy for wget without exposing credentials in my shell history?
Use environment variables or a temporary script instead of typing the password directly. For example, export PROXY_PASS and pass it with --proxy-password="$PROXY_PASS". You can also use --ask-password for interactive runs if your system supports it. This keeps credentials out of history and logs.
Does wget support SOCKS5 proxies?
No. wget has no native SOCKS5 support; it only handles HTTP, HTTPS and FTP proxies. Use proxychains4 to route wget through a SOCKS proxy, or switch to curl if SOCKS is a regular requirement.
What's the difference between setting http_proxy env vars and .wgetrc?
An environment variable is scoped to the shell or script that exported it and vanishes once that session closes. A .wgetrc file, by contrast, is consulted on each wget run, so it persists across sessions. On Windows the per-user file sits at C:/Users/<user>/.wgetrc instead of ~/.wgetrc.
How do I bypass the proxy for specific domains with wget (no_proxy)?
Assign no_proxy a comma-separated host list such as localhost,.internal.local. Requests that match those entries are sent straight to the destination even when a global proxy is configured — the right behavior for internal services that should never leave your network.
What's the simplest way to get rotating or geolocated IPs with wget?
Use a managed provider in API or proxy mode. That gives you rotation, geo-targeting and premium IP pools without maintaining lists, and it is the easiest reliable method at scale.
Does the proxy setup work with BusyBox wget (Alpine, Docker)?
BusyBox wget can proxy through http_proxy and https_proxy, but it is a trimmed-down build: the --proxy-user and -e options that GNU wget offers are simply not there. When the proxy needs credentials, put them in the URL itself (http://USER:PASS@HOST:PORT). If you need the full option set, install GNU wget in Alpine with apk add wget.