The “wget failed: Connection timed out” error occurs when wget is unable to establish a connection to the server within the specified timeout period.
This can happen due to various reasons, such as network issues, firewall settings, or problems on the server-side.
Here are some steps you can take to troubleshoot and fix this issue:
Table of Contents
Check your internet connection
Verify that your internet connection is active and stable. Open your web browser and try accessing other websites to ensure you can connect to the internet successfully. If you can’t access any websites, the issue might be with your internet connection rather than wget.
You can also command line tool like ping to check the network connectivity.
Here’s a quick overview of how to use the ping command:
- Open your terminal or command prompt.
- Type the following command and replace example.com with the domain name or IP address of the target host you want to ping:
ping actual IP address
- Press Enter.
The ping command will start sending ICMP echo requests to the target host. You will see the responses (ICMP echo replies) if the host is reachable, along with details like the round-trip time and any potential packet loss. The output will look something like this:
PING example.com (22.214.171.124) 56(84) bytes of data.
64 bytes from 126.96.36.199: icmp_seq=1 ttl=57 time=7.89 ms
64 bytes from 188.8.131.52: icmp_seq=2 ttl=57 time=8.05 ms
64 bytes from 184.108.40.206: icmp_seq=3 ttl=57 time=7.82 ms
If the target host is reachable, you will see responses showing the round-trip time (measured in milliseconds) for each packet.
If the host is not reachable, you will see a message indicating that the ping request has timed out or other error messages.
The ping command is a quick and straightforward way to check basic network connectivity to a specific host. It’s useful for verifying if a server or website is online and responsive.
Retry the download
Servers can sometimes be temporarily overloaded or experiencing high traffic, leading to connection timeouts.
Wait for a few minutes and then try the wget command again. If the server is back to normal, the download should proceed without issues.
Increase the timeout value
By default, wget sets a timeout of 15 seconds. If the server you are trying to access is slow or the connection is unstable, increasing the timeout value can give the server more time to respond, which may help to avoid the “Connection timed out” error.
To increase the timeout value for wget, you can use the –timeout option followed by the desired timeout duration in seconds.
Here’s how you can do it:
wget --timeout=30 https://example.com/file.txt
In the above example, wget will attempt to download the file.txt from the URL https://example.com/, and it will wait for a response from the server for up to 30 seconds.
If the server responds within that time, the download will proceed normally. If the server does not respond within 30 seconds, wget will terminate the connection and display a timeout error message.
You can adjust the timeout value according to your specific needs.
Remember that setting a longer timeout might increase the overall download time, especially if the server is slow or has a high response time. Therefore, choose a suitable timeout value based on your network conditions and the typical response time of the server you are connecting to.
Use a different mirror or server
Some websites and projects host their files on multiple mirrors or servers. If you encounter a timeout with one mirror, try another mirror or a different server URL if available. This can help you bypass issues with a specific server.
wget --timeout=30 https://mirror.example.com/file.txt
Some networks or servers may have issues with IPv6 connectivity. By using the –inet4-only option, you force wget to use only IPv4 for the connection, which may resolve the timeout issue.
wget --inet4-only https://example.com/file.txt
Check firewall settings
Temporarily Disabling the Firewall: To check if the firewall is causing the issue, you can temporarily disable it (if you have the necessary permissions) and then attempt the wget command again.
The command to disable the firewall can vary depending on your operating system and the firewall software you are using.
Example on Ubuntu with UFW (Uncomplicated Firewall):
On Ubuntu and other Debian-based systems that use UFW, you can disable the firewall using the ufw command with disable option. Run the following command with superuser privileges:
sudo ufw disable
Note: Disabling the firewall should only be done for troubleshooting purposes and only if you understand the potential security risks.
Leaving the firewall disabled for an extended period is not recommended, as it exposes your system to potential threats from the internet.
After disabling the firewall, try using wget again to download the file:
Check proxy settings
If you are behind a proxy server, ensure that your proxy settings are correctly configured in your environment. Incorrect proxy settings can prevent wget from reaching the internet.
Check DNS resolution
The “Connection timed out” error can occur when the domain name cannot be resolved to an IP address.
Use the dig command to check if the domain name is resolving correctly. If it doesn’t, there might be DNS issues on your system or network.
dig (Domain Information Groper) is a command-line tool that is commonly used to query DNS servers and retrieve DNS-related information, including IP addresses associated with domain names.
It provides more detailed information about DNS records, making it useful for DNS troubleshooting and diagnostics.
Here’s how you can use the dig command to check DNS resolution:
- Open your terminal or command prompt.
- Type the following command and replace example.com with the domain name you want to check: dig example.com
If you want to check a specific DNS record type, you can specify it after the domain name. For example, to query the A record (IPv4 address) for example.com, you can use:
Similarly, you can query other record types like CNAME, MX, TXT, etc.
- Press Enter.
The dig command will send a DNS query to the default DNS resolver (usually your local DNS server) and display the response.
The output will include information such as the domain’s IP address (A record), mail server information (MX record), alias information (CNAME record), and other DNS-related data.
Example output for dig example.com:
; <<>> DiG 9.11.3-1ubuntu1.22-Ubuntu <<>> example.com
;; global options: +cmd
;; Got answer:
;; AUTHORITY SECTION:
example.com. 83799 IN NS b.iana-servers.net.
example.com. 83799 IN NS a.iana-servers.net.
example.com. 83799 IN NS c.iana-servers.net.
example.com. 83799 IN NS d.iana-servers.net.
;; ADDITIONAL SECTION:
b.iana-servers.net. 1800 IN A 220.127.116.11
a.iana-servers.net. 1800 IN A 18.104.22.168
c.iana-servers.net. 1800 IN A 22.214.171.124
d.iana-servers.net. 1800 IN A 126.96.36.199
... (additional DNS data)
The output provides detailed information about the DNS query and its response, including the IP address associated with the domain name (A record) and the authoritative name servers for the domain (AUTHORITY SECTION).
Using the dig command, you can verify if the DNS resolution is working correctly for a specific domain name and view additional DNS-related information that may help with troubleshooting DNS issues.
Try a different network
If you have access to another network, such as a mobile hotspot or a different Wi-Fi network, try using wget from there. If the download works on the other network, it suggests that the issue lies with your original network configuration.
Contact the server administrator
If none of the above steps resolve the issue, the problem may be on the server’s end. The server you are trying to access might be down, experiencing technical difficulties, or blocking requests. Reach out to the server administrator or website owner to inquire about the issue and seek further assistance.
Always remember that the “Connection timed out” error can be caused by various factors, and it may take some troubleshooting to pinpoint the specific cause in your particular situation.