| by Arround The Web | No comments

How to Resolve the “Curl Could Not Resolve Host” Error in Linux

The “Curl Could Not Resolve Host” usually occurs when the curl cannot create a connection between the host and the server. In other words, this error occurs when the DNS resolution does not find the IP address with the specific hostname. Moreover, this error also occurs due to other issues, including:

  • Network connectivity issues
  • Typing mistakes in the command
  • DNS server problems and configuration issues
  • The firewall is blocking the connection
  • ISP-related issues

Although there are a few ways to resolve the error quickly, many beginners don’t know how to do it. So, in this blog, we will explain the various methods to resolve the “Curl Could Not Resolve Host” error in Linux.

How to Resolve the “Curl Could Not Resolve Host” Error in Linux

Let’s divide this section into multiple parts to explain the various processes to resolve the “Curl Could Not Resolve Host” error.

1. Check for the Typing Mistakes
Typing mistakes is the most common error that many Linux users make while using the “curl” command. For example, the following command has typing mistakes that lead to the “Curl Could Not Resolve Host” error:

curl https://linuxh.com

Hence, check the command that you are using to set up the connection.

2. Network Connectivity
Please make sure that the internet connection is stable and correctly working. You can restart the networking service as it can refresh the DNS settings.

systemctl restart NetworkManager

Or

/etc/init.d/network restart

3. The DNS Server
If the previous processes don’t resolve the error, you can check the DNS server configuration. You can run the following command to open the “config” file and add a new nameserver in it:

 sudo nano /etc/resolv.conf

For example, let’s add the new nameserver as shown in the following command:

Linuxhint 192.108.101.01

4. The /etc/hosts File
Sometimes, the hostname can also show the “Curl Could Not Resolve Host” error, so try to check the “/etc/hosts” by running the following command:

sudo nano /etc/hosts

In case the hostname is already defined, make sure to remove it and save the file.

Conclusion

This is how you can easily check and resolve the “Curl Could Not Resolve Host” error in Linux. The provided methods are simple and can resolve the error without facing issues. If the error is not resolved through the given methods, we recommend you to contact your ISP or network administrator and address the issue.

Share Button

Source: linuxhint.com

Leave a Reply