How to Use Wget With a Proxy: Setup, Authentication, and Troubleshooting

How to Use Wget With a Proxy: Setup, Authentication, and Troubleshooting
Ryan Chen

Ryan Chen

2026-11-23 3 phút đọc

Wget is a command-line download tool that many collection and automation scripts rely on. When a task needs requests to exit from a specific network, wget needs a proxy configured. This article starts with a minimal working example you can copy and adapt, then covers the three configuration methods, authentication, connection verification, and the most common errors, so wget requests can exit through a 9HTTP proxy within minutes.

Here is the shortest usable setup — replace the placeholders with your own values:

export http_proxy="http://username:password@proxy-host:port"
export https_proxy="http://username:password@proxy-host:port"
wget https://api.ipify.org
  • proxy-host — the proxy hostname from your provider's dashboard
  • port — the proxy port
  • username / password — your proxy credentials; drop this part entirely if your account uses IP whitelist authentication

If the last command prints an IP that is not your own, wget is already exiting through the proxy. The rest of this article explains each method in detail.

Note: the examples below were written against GNU Wget 1.21 on Linux and macOS. Option names have been stable across recent versions, but verify against wget --version if you are on an older build.

Before You Start

Two things to check before configuring anything:

Check your wget version. Run wget --version. GNU Wget 1.x supports HTTP, HTTPS, and FTP out of the box; SOCKS support depends on the build and version (see the FAQ). Most Linux distributions and macOS (via Homebrew) ship a current 1.21.x release, which is what the examples assume.

Prepare your proxy parameters. From the 9HTTP dashboard, copy three things: the hostname, the port, and the authentication method (username and password, or a whitelisted IP). Where these fields live and what each one means is covered in How to Find Your Proxy Server Address and Port.

If wget is not installed, install it with your system's package manager — for example apt install wget on Debian/Ubuntu or brew install wget on macOS. Installation is otherwise out of scope here.

How to Configure a Proxy in Wget

Wget reads proxy settings from three places. Pick one — or combine them, knowing which takes precedence.

Method 1: Environment variables

Set the proxy in your shell session before running wget:

export http_proxy="http://proxy-host:port"
export https_proxy="http://proxy-host:port"

Wget also honors ftp_proxy for FTP downloads. These variables only live in the current shell session — they disappear when you close the terminal, which makes this the right choice for quick tests.

Method 2: One-off configuration on a single command

To send one specific request through a proxy without touching your shell, pass the setting inline with -e:

wget -e use_proxy=yes -e http_proxy="http://proxy-host:port" https://example.com/page.html

For HTTPS URLs, use -e https_proxy=... instead. One-off configuration is useful in scripts where different requests should use different exits.

Method 3: Persistent configuration with .wgetrc

To make wget use a proxy for every request, add the settings to wget's initialization file ~/.wgetrc (per user) or /usr/local/etc/wgetrc (system-wide):

use_proxy = on
http_proxy = http://proxy-host:port
https_proxy = http://proxy-host:port

This applies to all future wget runs in your account. To turn the proxy off temporarily without deleting the file, run wget with --no-proxy (see the FAQ).

Precedence: a setting passed with -e on the command line overrides the value in .wgetrc, and .wgetrc overrides environment variables. If your configuration "does not work", the first thing to check is that another layer is not overriding it.

How to Authenticate With a Proxy

Most paid proxy services require authentication. Wget supports both standard ways:

Option 1: Credentials in the proxy URL

Embed the username and password directly in the proxy address:

export http_proxy="http://username:password@proxy-host:port"

If your password contains special characters such as @, :, /, or #, they must be URL-encoded first — for example, @ becomes %40 and : becomes %3A. An unencoded special character is the most common cause of authentication failures in wget.

Option 2: Dedicated command-line options

Pass credentials separately, which avoids URL-encoding issues:

wget --proxy-user=username --proxy-password=password \
     -e use_proxy=yes -e http_proxy="http://proxy-host:port" \
     https://example.com/page.html

You can also put proxy_user = username and proxy_password = password in ~/.wgetrc for persistent authentication.

Credential storage cautions

.wgetrc stores credentials in plain text, so treat it like any other secrets file:

  • Restrict permissions: chmod 600 ~/.wgetrc, so only your account can read it.
  • Avoid committing .wgetrc to repositories or copying it into shared scripts.
  • If your provider supports IP whitelist authentication, consider using it for servers and cron jobs instead of a password — after whitelisting your machine's IP, no credentials are needed at all. The trade-offs of the two methods are covered in Proxy IP Whitelist vs. Username/Password Authentication.

How to Verify the Proxy Connection

After configuring, confirm that wget traffic actually exits through the proxy — this takes one request:

wget -qO- https://api.ipify.org

This asks a public IP-checker service what IP it sees. Compare the result:

  • The output matches your proxy's IP (check the value in your provider's dashboard) — the configuration is live; wget requests are exiting through the proxy.
  • The output shows your own IP — wget is still connecting directly. The usual causes: the environment variables were set in a different shell session, .wgetrc is in the wrong path, or another setting is overriding this one (see the errors section below).
  • The request fails entirely — the proxy itself may be unreachable or the credentials are wrong; continue with the error list below.

If you need proxy resources for wget-based collection tasks, this is the point to pick a product: rotating exits for broad coverage (Dynamic Residential Proxies, from $0.22/GB) or a fixed exit for tasks that need one identity (Long Acting Static ISP, from $2.50/IP).

Common Wget Proxy Errors and Fixes

407 Proxy Authentication Required

The proxy rejected your credentials. Check three things in order: the username and password are correct; special characters in the password are URL-encoded or the credentials are passed with --proxy-user / --proxy-password; the credentials belong to the same account as the proxy host you are connecting to. The error itself and its variants are explained in What Is 407 Proxy Authentication Required?

Connection timed out

Wget could not reach the proxy at all. Typical causes: the hostname or port is wrong (re-copy both from the dashboard); a firewall on your machine or network blocks outbound traffic to the port; you set http_proxy but the target URL is HTTPS (wget uses https_proxy for HTTPS URLs — set both to be safe). Test whether the proxy endpoint itself is reachable with curl -x http://proxy-host:port https://api.ipify.org before blaming wget.

Unknown host / name resolution failures

The proxy hostname cannot be resolved. Check for typos in the hostname, confirm whether your provider requires a region-specific subdomain, and note that DNS resolution of the target website still happens through the proxy connection itself — a name-resolution error on the target site usually means the proxy connection failed rather than your local DNS being broken.

The target site refuses the request

If the proxy works (the IP check passes) but the target site returns errors or empty pages, the site is responding based on its own rules — request rate, account status, or its terms. Slow your request rate, keep the crawler's headers reasonable, and make sure you have authorization to collect from the site and comply with its terms of service. A proxy changes where requests come from; it does not change whether you are allowed to access the destination.

Frequently Asked Questions

How do I turn the proxy off in wget?

For the current shell session: unset http_proxy https_proxy ftp_proxy. For .wgetrc: set use_proxy = off, or delete the proxy lines. For a single command, add --no-proxy. A one-off -e setting only applies to that command, so nothing to clean up there.

My proxy configuration is not taking effect — why?

Work through the precedence chain: command-line -e settings override .wgetrc, and .wgetrc overrides environment variables — so an old setting may be winning. Also check that you set https_proxy (not just http_proxy) for HTTPS URLs, that the shell session where you exported the variables is the same one running wget, and that the IP check (api.ipify.org) shows the proxy IP rather than your own — if it shows your own IP, wget is not using any proxy at all.

Does my wget version support the protocol I need?

Run wget --version. GNU Wget 1.x handles HTTP, HTTPS, and FTP; SOCKS proxy support (--socks4, --socks5) depends on the version and build — if your build lacks SOCKS, use an HTTP/HTTPS proxy port instead, which most proxy providers offer alongside SOCKS5. HTTPS through an HTTP proxy works via CONNECT tunneling and does not require SOCKS.

Conclusion

Wget works with a proxy through three configuration layers — environment variables for quick tests, -e for one-off commands, and .wgetrc for persistent setups — with authentication via URL-embedded or --proxy-user / --proxy-password credentials. Verify the setup with a single IP-checker request, and when something breaks, work through the errors in the order "credentials → reachability → the target site's rules". Replace the placeholders in the examples with the parameters from the 9HTTP dashboard, run through the checks above, and wget requests will exit through the proxy reliably and repeatably.



Ryan Chen

Ryan Chen

SEO Content Specialist

Ryan brings experience in SEO content strategy and brand communications, creating clear, practical content that aligns with search intent and readers’ needs.

Nội dung Blog 9HTTP được cung cấp nguyên trạng, chỉ để tham khảo. Chúng tôi không đảm bảo về nội dung hoặc các trang được liên kết. Trước khi thu thập dữ liệu, hãy tham khảo tư vấn pháp lý, tuân thủ điều khoản trang web và luật hiện hành, đồng thời xin các quyền cần thiết.

Xem tất cả bài viết