Key takeaways
- Command-line flags are the quickest way to route a single download without changing your system settings.
- Updating your configuration file sets a permanent proxy, which saves you from typing long commands every time.
- Wget does not natively support SOCKS5 proxies, so you will need a wrapper like Proxychains to handle those connections.
GNU Wget is a reliable tool for fetching files from the web, and it works easily with proxies to hide your IP address or bypass local blocks. You can route your traffic through a proxy in three ways: adding a quick flag to your command, setting a temporary shell variable, or saving the details permanently in your configuration file.
wget -e use_proxy=yes -e http_proxy=http://192.168.1.100:8080 https://httpbin.org/
Method 1: use a proxy for one Wget command
To route a single download through a proxy server without changing your system proxy settings, you’ll need to append specific flags to your Wget command. It keeps your environment clean since the parameters disappear when the download completes.
Use an HTTP proxy
Pass the proxy details using the execute flag (-e) twice: once to activate the proxy feature and again to set the proxy address and port.
wget -e use_proxy=yes -e http_proxy=http://HOST:PORT https://httpbin.org/
Use a proxy for HTTPS requests
Secure connections require the https_proxy variable instead. Note that the proxy URL itself still uses http://. Wget connects to the proxy in plaintext and then opens an encrypted tunnel to the target using the HTTP CONNECT method. Only use https:// if your provider explicitly offers a TLS-terminating proxy endpoint.
wget -e use_proxy=yes -e https_proxy=http://HOST:PORT https://httpbin.org/
Use an authenticated proxy
If your proxy requires credentials, add your proxy username and proxy password as separate flags during the proxy configuration. Be careful doing this, as typing plain-text passwords directly into the terminal leaves a permanent record in your shell history.
wget -e use_proxy=yes -e http_proxy=http://HOST:PORT --proxy-user=USER --proxy-password=PASS https://httpbin.org/
Method 2: set Wget proxy environment variables
If you need to run multiple downloads in one terminal session, export your proxy URL and other proxy configuration details as environment variables for GNU Wget. It saves you from typing out flags for every command, and the settings automatically clear out when you close the terminal window.
Linux and macOS
Use the export command to assign your proxy URL to standard environment variables when using a proxy server. Wget and most other command-line tools will automatically look for these.
export http_proxy="http://HOST:PORT"
export https_proxy="http://HOST:PORT"
Make proxy variables persistent
To load these variables automatically every time you open a terminal, add the export commands to your shell configuration file, like .bashrc or .zshrc. The system will then apply them whenever it starts up.
Windows PowerShell
In Windows, you can set session-level variables directly using PowerShell.
$env:http_proxy="http://HOST:PORT"
$env:https_proxy="http://HOST:PORT"
Method 3: configure a proxy in wgetrc
To use a proxy by default, add your settings to the wgetrc file. It makes your configuration permanent so you do not have to manage shell variables or type out lengthy flags every time you run Wget.
Configure a proxy for the current user
To apply proxy settings just to your own account, create or edit the hidden .wgetrc file for GNU Wget as part of your proxy configuration.
# ~/.wgetrc
use_proxy = on
http_proxy = http://HOST:PORT
https_proxy = http://HOST:PORT
Configure a system-wide proxy
To apply these settings to all users, modify the global /etc/wgetrc file. You will, however, need higher permissions to edit the configuration, and the changes will affect anyone running Wget on that device.
Add proxy authentication to wgetrc
If your proxy requires credentials, you can add your proxy username and password directly to the configuration file for the proxy server. Because it stores your password in plain text, be sure to restrict read permissions on your .wgetrc file to prevent unauthorized access.
use_proxy = on
http_proxy = http://HOST:PORT
proxy_user = YOUR_USERNAME
proxy_password = YOUR_PASSWORD
Which Wget proxy method should you use?
Command-line flags
One-off downloads
Leaves no permanent configuration traces
Tedious for multiple downloads
Environment variables
Single terminal sessions
Affects multiple commands without altering system files
Settings disappear when the terminal closes
User .wgetrc
Persistent daily use
Automates Wget downloads for your user account
Stores passwords in plain text if authentication is used
System /etc/wgetrc
Server-wide setups
Applies proxy settings to all Wget users on the system
Requires administrative privileges to modify
How to check whether Wget is using the proxy
Check if your proxy server works by fetching a service that returns your public IP address using a standard Wget command. Run the command without a proxy to see your normal IP, then run it again with the proxy flags. The second output should display the proxy's IP.
wget -qO- https://api.ipify.org
wget -qO- -e use_proxy=yes -e https_proxy=http://HOST:PORT https://api.ipify.org
Bypass the proxy for specific hosts with no_proxy
If you need to download files from a local server while a global proxy is active, use the no_proxy variable. Set it to a comma-separated list of the domains or IP addresses you want to exclude.
export no_proxy="localhost,127.0.0.1,internal.local"
Does Wget support SOCKS5 proxies?
Wget only supports HTTP, HTTPS, and FTP protocols natively. It cannot communicate directly with SOCKS5 proxies. To route traffic through a SOCKS tunnel, you must use a third-party tool.
Use Wget with Proxychains
Proxychains intercepts network calls at the system level and routes them through your configured proxy. Just prefix your standard Wget command with proxychains.
proxychains wget https://httpbin.org/
When another tool may be easier
If you need native SOCKS5 support or complex authentication, consider switching tools. Read our cURL vs Wget guide to see how cURL handles advanced connections natively without external wrappers.
Common Wget proxy errors and fixes
407 Proxy Authentication Required
It means the proxy requires valid credentials, so you may have accidentally misspelled or added the wrong credentials. Check your username and password, and ensure you are passing them in the exact format your provider expects.
Connection refused
It typically means the proxy server is offline, a firewall is blocking the connection, or you specified the wrong host or port. To fix it, verify the proxy server's IP address and port number, then confirm the proxy server is reachable from your network.
Wget is ignoring the proxy
If Wget connects directly to the target, you might be using the http_proxy variable for an HTTPS URL. Make sure you use https_proxy for secure connections. Additionally, check that the target domain is not accidentally listed in your no_proxy environment variable.
HTTPS certificate errors
If your proxy performs SSL inspection, it will present a certificate that Wget does not recognize natively. You can append the --no-check-certificate flag to bypass this security check, but be aware that this exposes you to potential man-in-the-middle attacks.
Proxy connection times out
It usually means the proxy is unreachable or your network connection dropped. While you can try pinging the proxy IP to check if it’s online, be aware that many servers block ping requests. If the proxy is definitely online, the target website might be blocking the proxy network entirely.
Wget Proxy command cheat sheet
One-off HTTP proxy:
wget -e use_proxy=yes -e http_proxy=http://HOST:PORT https://httpbin.org/
HTTPS proxy:
wget -e use_proxy=yes -e https_proxy=http://HOST:PORT https://httpbin.org/
Authenticated proxy:
wget -e use_proxy=yes -e http_proxy=http://HOST:PORT --proxy-user=USER --proxy-password=PASS https://httpbin.org/
Environment variables:
export http_proxy="http://HOST:PORT"
export https_proxy="http://HOST:PORT"
Wgetrc:
use_proxy = on
http_proxy = http://HOST:PORT
https_proxy = http://HOST:PORT
No_proxy:
export no_proxy="localhost,127.0.0.1"
Final thoughts
Configuring a Wget proxy server allows you to hide your local IP address and route traffic through custom gateways. While Wget has some limitations with native SOCKS5 support, environment variables and configuration files give you plenty of flexibility for different network setups.
If you need a reliable proxy service to use with your terminal workflows, providers like MarsProxies offer compatible gateways.
Frequently asked questions
How do I use a proxy with Wget?
Append the -e use_proxy=yes and -e http_proxy=http://HOST:PORT flags to your command to route a download through the proxy.
How do I use a username and password with a Wget proxy?
Pass the --proxy-user=USERNAME and --proxy-password=PASSWORD flags directly in your command, or add them to your .wgetrc configuration file.
Should I use http_proxy or https_proxy with Wget?
Use http_proxy for standard unsecured HTTP traffic, and use https_proxy for encrypted HTTPS connections.
How do I disable a proxy in Wget?
Use the --no-proxy flag on a specific download to bypass any active proxy configuration and connect directly to the target server.
Why is Wget not using my proxy?
This usually happens due to a configuration conflict. Your wgetrc file settings silently override environment variables, and command-line flags override both. Also check that the use_proxy = on directive is present in your wgetrc file.