Read Timeout vs Connect Timeout in Wget

When downloading files using the wget command-line tool, network disruptions can cause your downloads to stall or fail. To handle these situations gracefully, wget utilizes two distinct timeout parameters: connect timeout and read timeout. While both are designed to prevent the tool from hanging indefinitely, they trigger at completely different stages of the network request process. Understanding the difference between them ensures your automated scripts and downloads handle network instability efficiently.

What is Connect Timeout?

The connect timeout determines how long wget will wait to establish a fundamental connection with the destination server. When you initiate a download, wget must first perform a “TCP handshake” to open a communication channel with the host.

What is Read Timeout?

The read timeout comes into play after a successful connection has already been established with the server. Once connected, wget expects a continuous stream of data from the host.

Key Differences at a Glance

The fundamental differences between these two timeout settings can be broken down by their timing, default behaviors, and primary causes:

Feature Connect Timeout (--connect-timeout) Read Timeout (--read-timeout)
Phase Before the connection is established. After the connection is established.
Trigger Event Failure to complete the TCP handshake. Failure to receive new data chunks mid-stream.
Primary Cause Server is offline, wrong IP, or blocked by a firewall. Server crashed mid-process, or network dropped during transit.
Wget Default No default timeout (relies on the OS system timeout). 90 seconds.

Combining Options for Reliable Scripts

In unstable network environments, relying on just one of these settings can leave your scripts vulnerable to hanging. For the most robust automation, it is best practice to define both timeouts explicitly in your command.

wget --connect-timeout=10 --read-timeout=15 https://example.com/largefile.zip

In this example, wget will give up quickly (10 seconds) if the server is completely unreachable, but will allow a slightly longer grace period (15 seconds) if the data stream temporarily stutters during the actual file transfer.