Commands.page Logo

How to Set Wget Maximum Retries on Ubuntu

This guide provides a direct answer to configuring download attempts using the wget utility on Ubuntu. It outlines the specific command-line option required to limit retries, explains the default behavior, and offers practical examples for both standard usage and script automation to prevent hanging processes.

To set the maximum number of retries for a failed wget download, use the -t or --tries option followed by the desired number. By default, wget will attempt to download a file 20 times before giving up. You can change this value to suit your network stability or scripting requirements.

Basic Syntax

wget -t [number] [URL]

Examples

To limit wget to 5 retry attempts:

wget -t 5 https://example.com/file.zip

To disable retries completely and fail immediately after the first attempt:

wget -t 1 https://example.com/file.zip

To set infinite retries until the download succeeds:

wget -t inf https://example.com/file.zip

Using this option ensures that your Ubuntu system does not waste resources indefinitely trying to reach an unreachable server.