In this tutorial, we will learn about how to fix the error curl: (28) Failed to connect to cloud-images.ubuntu.com port 443 after 42094 ms on Windows System. This error indicates the connection timeout issue while sending the curl request. There can be several reasons behind this error. For examples, unstable network, server is not reachable, invalid SSL certificate and so on. We will look at different ways to address and fix this error. We will also try to reproduce the error in the Windows system. So let us begin the tutorial.
How to Reproduce the Error?
Also Read: How to Install Istio on Windows 10 [4 Easy Steps]
When I was downloading the Ubuntu22.04 archive in my Windows machine, I encountered this error. This archive is basically required to install and configure WSL in Windows system. So, I used the curl command to download the archive and save in the current directory. After few seconds I see exactly the same error in response as shown below.
C:\Users\linuxnasa.com>curl -O https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-root.tar.xz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:42 --:--:-- 0 curl: (28) Failed to connect to cloud-images.ubuntu.com port 443 after 42094 ms: Couldn't connect to server
Why the Error Occured?
The error “curl: (28) Failed to connect to cloud-images.ubuntu.com port 443 after 42094 ms” may occur due to several reasons. For example, slow network, low timeout values, firewall issues or any other network related error in the system. It may also be possible that the server(in this case images.ubuntu.com) is not reachable. We will address some of these error cause and try to fix the error in the next section.
How to Fix the error?
There are several ways to address and fix the error. We will try the permutation and combination of below given fixes as reason could be anything for this error. Let us look at each solution one by one.
Solution-1: Check Network Connection
Check and ensure that there are no network errors. To verify, you can simply try to access other websites. For example, ping google.com. Below command will send the HTTP GET request to google. If you get the HTML response it means network connection is working. If there are any network error you will get the error in response.
curl http://www.google.com
Solution-2: Timeout Setting
Another thing you could do is to set a specific timeout value while executing the curl command. To do so, use -m
option to set a specific timeout value while sending the curl request as shown below.
curl -m 60 http://www.google.com
Solution-3: Disconnect from VPN
In this method, disconnect from the VPN if you are connected. Sometimes VPN creates network constraints, leading to timeout during curl requests. The VPN might have caused delays or disruptions in the connection to the server, resulting in the timeout error. After disconnect from VPN, try to download the archive again. This time the download will work as shown below.
C:\Users\linuxnasa.com>curl -O https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-root.tar.xz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 392M 100 392M 0 0 9271k 0 0:00:43 0:00:43 --:--:-- 10.0M
List the files and check if it is saved in the current directory.
C:\Users\linuxnasa.com>dir Volume in drive C is System Volume Serial Number is 3619-231E Directory of C:\Users\linuxnasa.com 25-12-2023 12:23 411,686,628 jammy-server-cloudimg-amd64-root.tar.xz
Summary
We have fixed the curl timeout error using one of the fixes given in this tutorial. Learn more about curl command line tool and its usage from their official website curl.se.