How to Specify a Custom Port for Wget on Ubuntu
This article provides a concise guide on configuring the wget command-line utility within the Ubuntu operating system to connect to servers using non-standard ports. It clarifies the specific syntax required to define port numbers, ensuring users can successfully download files from services that do not run on the default HTTP or HTTPS ports.
Unlike some other network tools, wget does not use a separate command-line flag to define the port number. Instead, you must specify the custom port directly within the URL string itself. To do this, add a colon followed by the port number immediately after the domain name and before the file path.
The standard syntax looks like this:
wget http://example.com:PORT_NUMBER/path/to/file
For example, if you need to connect to a web server running on port 8080 instead of the default port 80, your command would be:
wget http://example.com:8080/index.html
This method applies to both HTTP and HTTPS connections. If you are connecting to a secure server on a custom port, simply include the port number in the same manner:
wget https://example.com:8443/secure-file.zip
By embedding the port number into the URL, wget automatically directs the connection request to the correct network port without requiring additional configuration options or flags.