Use Wget Setting a Timeout and Maximum Number of Tries

Last Updated: Wed, July 27, 2022

Setting a timeout

Set the network timeout to seconds. This is equivalent to specifying --dns-timeout, -connect-timeout, and --read-timeout simultaneously.
When interacting with the network, Wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a timeout to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings.

You can set a timeout by using the -T (or --timeout) option followed by the time in seconds.

Useing this command you can set the timeout to 5 seconds.

wget -T 5 https://vpsname.com/favicon.ico

Maximum Number of Tries

You can also set how many times Wget attempts to download a file after being interrupted by passing the -t (or --tries) option followed by the number of tries.

Using this command, you can limit the number of tries to 3.

wget -t 3 https://vpsname.com/favicon.ico

The default is to retry 20 times, with the exception of fatal errors like "connection refused" or "not found" (404), which are not retried.


If you interest in my articles, please consider buying me a coffee.

Write Your Comment