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

H
“Curl could not resolve host” usually occurs when curl cannot make a connection between the host and the server. In other words, this error occurs when DNS resolution does not find an IP address with a specific hostname. Additionally, this error is also caused by other problems, including:

  • network connectivity issues
  • Typing mistakes in commands
  • DNS server issues and configuration issues
  • Firewall is blocking the connection
  • ISP related issues

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

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

Let’s break this section into several parts to explain different procedures to resolve the “curl could not resolve host” error.

1. Check for typing mistakes
Typing mistakes are the most common error that many Linux users make when using the “curl” command. For example, the following command contains typing mistakes that cause a “curl could not resolve host” error:

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

2. Network Connectivity
Please ensure that the Internet connection is stable and working correctly. You can restart the networking service as it may refresh the DNS settings.

systemctl restart networkmanager

Or

,etc,init.d,network restart

3. DNS Server
If the previous procedures do not resolve the error, you can check the DNS server configuration. You can run the following command to open the “configuration” file and add a new nameserver to it:

sudo nano ,etc,resolution.conf

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

4. /etc/hosts file
Sometimes, the hostname may also show “Curl could not resolve host” error, so try to check “/etc/hosts” by running the following command:

If the hostname is already defined, make sure to delete it and save the file.

conclusion

Thus you can easily check and resolve “Curl Could Not Resolve Host” error in Linux. The methods provided are simple and can resolve the error without facing any problems. If the given methods do not resolve the error, we recommend you to contact your ISP or network administrator and resolve the issue.

Add comment

By Ranjan