How to Fix “curl:(6) Could not resolve host” Error in Linux

Linux is an Operating System whose core functionality revolves around the use of the command line terminal. Almost all of the tasks can be performed through the Linux terminal. Downloading from the web is one of these features. This is often accomplished using the curl command in the terminal. When utilizing this feature, an error can be encountered that has the statement “curl:(6) Could not resolve host”.

This article will shed some light on what is prompting these errors as well as what can be done to fix these issues.

How to Resolve the “curl:(6) Could not resolve host”?

There may be numerous reasons which will invoke this error. This section will not only elaborate on what these reasons are but also explain the necessary steps you can take to fix this problem.

Reason 1: Syntax Problem

The first and most obvious reason for a problem like this is that there is some issue with the curl command’s syntax. Usually, the syntax to curl is very simple to follow but even the slightest mistake can invoke the error as is shown in the snippet below:

It is very clearly seen that the syntax for the command above is incorrect. It is a very simple mistake that there is an unnecessary space in the link provided after curl.

Solution: Use the Correct Syntax

The only way to fix this issue is to follow the correct syntax of any curl command. The standard syntax for any curl command is as follows:

curl [options] [URL]

Now, let’s implement this syntax for the link shown above:

Now that the syntax problem has been avoided, we can see that the curl command works without any errors.

Reason 2: No DNS Nameserver

Nameservers act as a link between the domain name and the remote server of any web page. Instead of using the IP addresses, nameservers are utilized. But if the Nameserver is missing from your /etc/resolv.conf file then this error will be prompted.

Solution: Add DNS Nameserver

The simple solution to this issue is to add the nameserver of the URL to the file and save it. To add the nameserver, first, open the file using this command in the terminal:

$ sudo nano /etc/resolv.conf

This should open the file and we need to add the nameserver to the file using the following format:

nameserver ip.address

Check out the sample below to verify:

Once the nameserver is added, you can run the curl command with the link and the error will be resolved.


The “curl:(6) Could not resolve host” error occurs when the curl command is used with incorrect syntax or the DNS nameserver is missing. To fix it, you need to verify and check the syntax of the command or add a nameserver for the URL into your /etc/resolv.conf file. This article has provided a detailed guide on why the error “curl:(6) Could not resolve host” occurs and also the possible solutions to fix it.