Download failed. cURL error 28: Resolving timed out after some milliseconds

Published in

on

The error message “Download failed. cURL error 28: Resolving timed out after some milliseconds” indicates that the cURL command is timing out while trying to resolve a domain name. This usually happens because of DNS resolution issues or network connectivity problems due to multiple reasons that need to be understood.

Here are several steps you can take to troubleshoot and fix this issue:

1. Check web server’s internet connection.

Ensure that your internet connection is stable and working properly. Sometimes, intermittent connectivity can cause cURL to time out.

2. Check DNS settings.

Your DNS settings might be misconfigured.

Try using a different DNS server, such as Google’s DNS (8.8.8.8 and 8.8.4.4).

On Linux and macOS:

Edit the /etc/resolv.conf file to add the Google DNS servers:

sudo nano /etc/resolv.conf

Add the following lines:

nameserver 8.8.8.8
nameserver 8.8.4.4

Save the file and exit the editor.

On Windows:

  • Go to Control Panel > Network and Sharing Center > Change adapter settings.
  • Right-click on your network adapter and select Properties.
  • Select “Internet Protocol Version 4 (TCP/IPv4)” and click on Properties.
  • Use the following DNS server addresses:
Preferred DNS server: 8.8.8.8
Alternate DNS server: 8.8.4.4

3. Increase cURL timeout.

You can increase the timeout value for cURL to give it more time to resolve the domain name. If you’re encountering this issue within a PHP script, you can increase the timeout:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Increase timeout to 30 seconds
$response = curl_exec($ch);
curl_close($ch);

4. Check for firewall or security software.

Firewalls or security software might be blocking cURL requests.

Temporarily disable them to see if it resolves the issue.

If it does, configure the firewall or security software to allow cURL requests.

5. Update cURL and OpenSSL.

Ensure that cURL and OpenSSL are up-to-date.

An outdated version might cause connectivity issues.

On Linux:

sudo apt-get update
sudo apt-get upgrade curl
sudo apt-get upgrade openssl

On macOS:

brew update
brew upgrade curl
brew upgrade openssl

6. Verify server availability.

The server you are trying to reach might be down or experiencing issues. Verify that the server is up and running by using other tools like ping or nslookup:

ping example.com
nslookup example.com

7. Clear DNS cache.

Clearing your DNS cache can sometimes resolve connectivity issues.

On Linux:

sudo systemd-resolve --flush-caches

On macOS:

sudo killall -HUP mDNSResponder

On Windows:

Open Command Prompt as an administrator and run:

ipconfig /flushdns

8. Test with a different network (if available).

If possible, try connecting to a different network to see if the issue persists. This can help determine if the problem is specific to your current network.

By following these steps, you should be able to identify and resolve the issue causing the “cURL error 28: Resolving timed out” message.

Leave a Reply

Your email address will not be published. Required fields are marked *