Commands.page Logo

How to Download Files Using Wget With HTTP Proxy on Ubuntu

This guide explains how to configure the wget command-line utility to download files through an HTTP proxy server on Ubuntu. You will learn the specific syntax required to route traffic via a proxy, including methods for handling authentication credentials securely.

To download a file using wget behind a proxy, use the --http-proxy option to specify the server details directly in the command. The basic structure requires the protocol, IP address, and port number of your proxy server.

Run the following command in your terminal:

wget --http-proxy=http://proxy_ip:port http://example.com/file.zip

If your proxy requires authentication, include your username and password in the proxy URL string. Be aware that this may expose credentials in your shell history, so use it with caution on shared systems.

wget --http-proxy=http://username:password@proxy_ip:port http://example.com/file.zip

Alternatively, you can export the proxy settings as environment variables for the current session. This allows wget to detect the proxy automatically without additional flags for every command.

export http_proxy=http://username:password@proxy_ip:port
wget http://example.com/file.zip

For permanent configuration, add the export line to your .bashrc file. This ensures all future wget requests route through the proxy by default on your Ubuntu system.