How to Fix “Curl Could Not Resolve Host”

The error curl: (6) Could not resolve host means curl could not translate the hostname it was given into an IP address. The usual causes are a malformed command, an incorrect hostname, or DNS settings that do not work in the environment running curl. Start with the exact hostname in the error before changing network settings.

Use this table to choose the right starting point:

Symptom Likely Cause First Fix or Check
The error names POST, application, or part of a header Curl is treating a stray command argument as a URL Correct the options and quoting
Only one real hostname fails Typo, missing DNS record, or private DNS requirement Check the hostname and its DNS response
Several unrelated public domains fail Unreachable DNS resolver or broken network configuration Check the active connection and configured resolver
Curl works on the host but fails in a container, VM, or application Different DNS, network, or process configuration Run diagnostics inside the failing environment
Editing DNS settings helps only until a restart A network manager regenerates the configuration Make the change in the configuration owner
Curl fails only when a VPN or proxy is involved Split DNS, routing, or proxy configuration mismatch Check the required network path and proxy settings

What “Could Not Resolve Host” Means

Curl needs an address before it can connect to a named server. For a URL such as https://example.com/download, it first resolves example.com, then connects, negotiates TLS for HTTPS, and sends the request.

This error occurs during name resolution. It is not an HTTP response from the destination server, and changing your JSON body, API credentials, or certificate verification settings will not repair a genuine DNS failure.

However, the hostname curl tries to resolve might not be the hostname you intended. A misplaced argument can become an additional URL. A redirect can also introduce a different hostname, so read the name in the error rather than assuming the original destination failed.

If the message says “Could not resolve proxy,” the unresolved name belongs to the proxy, not necessarily the destination.

How to Fix Curl Could Not Resolve Host

Correct the command and hostname, then test DNS in the failing environment and restore the intended network and DNS path.

Step 1: Check the Hostname and Simplify the Command

  1. Identify the hostname curl reports after `Could not resolve host:` and compare it with the hostname you intended to request. Check it for misspellings, spaces, unexpected punctuation, and command fragments.
  2. Reduce the request to its URL and verbose output. Replace the example URL with your actual destination:
    curl -v "https://example.com/"

    On Windows, use curl.exe rather than curl if your shell maps that name to a PowerShell command.

  3. If the simplified request resolves successfully, restore the original options one at a time. Use straight quotation marks, not typographic “smart quotes,” and quote URLs containing shell-sensitive characters such as &.

A bare POST is not an instruction to curl: it can be interpreted as another URL. Use the --request POST option when an explicit method is necessary. For a normal JSON POST, a data option selects POST automatically.

For example, this command sends an existing file named payload.json. Replace the placeholder API URL before running it:

curl -v -H "Content-Type: application/json" --data-binary "@payload.json" "https://api.example.com/endpoint"

Similarly, an error naming application or a fragment of application/json points toward a broken header argument. Keep the entire header value quoted.

Curl can process multiple URLs in one invocation, so a stray argument can produce a resolution error even when another request succeeds. Finish this check by running the corrected full command and confirming that the unexpected hostname no longer appears.

Step 2: Test Resolution Where the Request Fails

The DNS configuration that matters is the one visible to the process making the request.

  1. Open a shell in the failing container, VM, server, CI runner, or application environment and run nslookup HOSTNAME, replacing HOSTNAME with the name in the error.
  2. Query the failing hostname. Replace HOSTNAME with the name from the error, without a scheme, path, or port:
    nslookup HOSTNAME
  3. Compare it with a public control domain:
    nslookup example.com
  4. On Linux, also test the system hostname lookup mechanism:
    getent ahosts HOSTNAME

Interpret the results before changing anything:

  • The target fails, but the control resolves: investigate the target’s spelling, DNS records, or private-network requirements.
  • Both fail: investigate the environment’s DNS configuration and network access.
  • DNS queries succeed, but the system lookup fails: inspect local hostname-resolution configuration, including /etc/hosts and /etc/nsswitch.conf.
  • Both succeed, but curl fails: investigate curl’s configuration, proxy use, resolver backend, and the actual application process.

An NXDOMAIN response means the queried resolver considers the name nonexistent. A timeout means it did not provide a response; that can indicate an unreachable resolver or dropped traffic. SERVFAIL indicates that the resolver could not complete the lookup.

Connect to the required VPN or use the organization’s intended DNS service, then repeat the target lookup and curl request.

Step 3: Restore the Intended Network and DNS Path

  1. Check network access to both the configured DNS resolver and the intended destination. Reconnect a disconnected network or required VPN before editing DNS settings. Restricted compute nodes and CI runners may require an approved proxy or a separate download-capable environment.
  2. On Linux, inspect the resolver configuration:
    cat /etc/resolv.conf

    On systems using systemd-resolved, inspect the active per-link DNS configuration:

    resolvectl status

    A local stub address such as 127.0.0.53 is not inherently wrong. It is expected on many systemd-resolved installations; the local resolver must be running and have usable upstream DNS servers.

  3. Check whether the configured resolver is reachable from this environment. For conventional DNS, network rules must allow queries and replies using UDP and TCP port 53. A failed ping alone does not establish that DNS is blocked.
  4. Correct the configuration through the component that owns it, such as NetworkManager, Netplan, DHCP, or the container platform, and apply the change. Then repeat the hostname lookup and original curl request.

Do not replace corporate or VPN DNS with a public resolver indiscriminately. That can break private names or send internal lookup requests outside the intended network.

Likewise, avoid treating a direct edit to /etc/resolv.conf as a permanent repair. If the file is generated, its contents can change when the connection renews or the machine restarts.

Step 4: Check Proxies and Hidden Curl Configuration

  1. Inspect proxy environment variables in the failing shell. They can contain credentials, so do not publish their values without redacting them. On a POSIX shell:
    env | grep -iE '^(http_proxy|https_proxy|all_proxy|no_proxy)='

    In PowerShell:

    Get-ChildItem Env:*proxy*
  2. Check for an explicit proxy in the command or application settings. Curl may use different proxy settings from your browser, and SOCKS configurations can differ in where hostname resolution happens.
  3. Test without curl’s default configuration file. The -q option must be the first curl option:
    curl -q -v "https://example.com/"

    This ignores the default curl configuration file; it does not clear proxy environment variables.

  4. If direct internet access is permitted, test a single invocation without a proxy:
    curl --noproxy "*" -v "https://example.com/"

If either test changes the result, correct the stale setting or hostname in the relevant configuration. Do not permanently bypass a required organizational proxy. Finish by rerunning the normal command without diagnostic overrides.

Step 5: Use a Known IP to Isolate DNS From Connection Problems

Use curl’s –resolve option with a verified destination IP to test the connection without relying on normal DNS resolution for that hostname. This provides a custom address for a specific hostname-and-port pair, as documented by the SANS Internet Storm Center.

  1. Obtain the destination IP from the service owner or authoritative infrastructure configuration. Do not guess an address or copy an unrelated result from another environment.
  2. Replace the hostname and IP in this example. The address shown is a documentation placeholder, not a working destination; port 443 is the default HTTPS port:
    curl -v --resolve "example.com:443:192.0.2.10" "https://example.com/"

    Use this as a direct-connection test where direct access is allowed. A proxy may resolve the destination itself, making this test inconclusive.

  3. Interpret the result: – If the request succeeds, the service is reachable at that address; focus on the normal hostname-resolution path. – If the error changes to a connection or TLS error, name resolution has been bypassed for that host, but another problem remains. – If a different hostname fails, check for a redirect or another destination.

Unlike replacing an HTTPS hostname with an IP address in the URL, --resolve preserves the URL hostname for TLS server-name indication and certificate verification. Adding a Host header to an IP-based HTTPS URL is not equivalent.

Remove the override after repairing DNS and rerun the original request. A hard-coded IP is a diagnostic aid, not a durable fix for a service whose addresses may change.

Fixes for Linux, Windows, Containers, and Applications

Apply persistent, environment-specific DNS corrections, then retry the hostname lookup and curl request from the affected workload or application.

Persistent DNS Settings on Linux

If a DNS edit disappears after reconnecting or rebooting, change the configuration that generates it.

For an IPv4 DNS override on a NetworkManager-managed connection, first identify the active connection:

nmcli connection show --active

Inspect and save its existing settings so you can restore them if necessary:

nmcli connection show "CONNECTION"

Replace CONNECTION with the connection name and DNS_IP with a resolver confirmed reachable and appropriate for this network:

sudo nmcli connection modify "CONNECTION" ipv4.dns "DNS_IP" ipv4.ignore-auto-dns yes

This replaces automatically supplied IPv4 DNS servers for that connection; it does not disable IPv6 or replace every other link’s DNS configuration.

Activate the updated connection:

sudo nmcli connection up "CONNECTION"

Reactivation can interrupt connectivity. On a remote server, have console access or a recovery path before doing it.

Verify the active resolver and retry the target request. If resolution becomes worse, restore the saved connection values and reactivate the connection. On systems managed by Netplan, systemd-networkd, or another service, make the persistent change there instead of applying NetworkManager commands.

Curl on Windows

Use the actual curl executable for diagnosis:

curl.exe -v "https://example.com/"

Inspect the DNS servers assigned to Windows interfaces:

Get-DnsClientServerAddress

If the active adapter has incorrect static DNS settings, open the network-adapter control panel:

ncpa.cpl

Open the active adapter’s Properties > Internet Protocol Version 4 (TCP/IPv4) > Properties. Restore Obtain DNS Server Address Automatically if the network supplies DNS through DHCP, or enter the network-approved static resolver addresses. Check IPv6 settings as well if they are part of the network configuration.

If the settings are correct but a stale cached result is suspected, clear the Windows DNS cache from an elevated terminal:

ipconfig /flushdns

Retry the hostname lookup and curl request. Flushing the cache does not repair an unreachable resolver, a misspelled domain, or a missing DNS record.

Docker and Kubernetes

A successful request on the host does not prove that a container or Pod has working DNS. Run the test inside the workload.

For Docker, replace CONTAINER with the container name or ID:

docker exec CONTAINER curl -v "https://example.com/"

For Kubernetes, replace NAMESPACE and POD with the workload’s values:

kubectl exec -n NAMESPACE POD -- curl -v "https://example.com/"

These commands require curl to be installed in the container. If it is absent, use your platform’s approved debugging image or container rather than modifying a production image just for diagnosis.

Check the failing environment’s resolver configuration and network:

  • Docker: verify its network attachment and any daemon-level or service-level DNS overrides.
  • Kubernetes: verify the Pod’s dnsPolicy, any dnsConfig overrides, cluster DNS health, and NetworkPolicy rules affecting DNS traffic.
  • Private service names: confirm that the caller is on the appropriate network or using a name valid in its Kubernetes namespace.

A host loopback address inside a container normally refers to the container itself, not the host’s resolver.

Apply the correction to the workload or platform configuration. Recreate or redeploy affected workloads when necessary, then repeat the request inside a newly started instance to confirm that the fix persists.

PHP, Guzzle, Laravel, and Virtual Machines

An application exception containing this curl error generally needs investigation below the HTTP client library.

Inspect the URL actually constructed at runtime, then test from the application’s execution environment. A hostname defined in your laptop’s hosts file is not automatically defined inside a Vagrant VM, container, or remote PHP service.

For a development hostname, add the appropriate mapping in the guest environment or use DNS or service discovery that the guest can access. For a production API, correct the runtime hostname, DNS configuration, or network path rather than hard-coding an address.

Finish by triggering the original application operation. A successful interactive shell test alone does not prove that the application service has the same environment or libcurl build.

Advanced Libcurl and DNS Routing Checks

Reproduce failures through the same libcurl path, then check custom DNS servers, source addresses, interfaces, and routing.

Resolver Differences and Custom DNS Servers

Successful tests with dig, resolvectl, nslookup, or libcurl’s easy interface do not rule out a failure in the multi interface. Reproduce the request through the same interface, process, and configuration that fails; resolver-backend behavior can differ in curl’s libcurl.

For curl’s libcurl, CURLOPT_DNS_SERVERS selects custom DNS servers when supported by the resolver backend. For example:

curl_easy_setopt(handle, CURLOPT_DNS_SERVERS, "8.8.8.8");

Here, 8.8.8.8 is Google’s public DNS resolver, not a universal repair value. Confirm the correct address against the network’s reachable, approved DNS-server configuration. A public resolver may be blocked, unroutable, or unable to answer private-domain queries.

Check the return value from the option-setting call. If custom DNS settings were added during troubleshooting, remove them temporarily, recreate the handles using system defaults, and repeat the failing operation.

If the failure remains specific to the application path, inspect whether DNS queries leave the process’s network environment and whether replies return. Capture traffic only where authorized, and remove experimental overrides before the final application test.

DNS Source Address and Network Interface

On a multihomed system, DNS queries may leave through an unintended interface or source address. Curl provides targeted tests for this, but the relevant options require a build with c-ares support.

Inspect the build information:

curl --version

Look for c-ares in the version output.

On Linux, list interfaces and their addresses:

ip -brief address

To test a specific IPv4 source, use curl’s --dns-ipv4-addr option. Replace 172.16.0.20 with an address actually assigned to the interface being tested:

curl --dns-ipv4-addr 172.16.0.20 -v "https://example.com/"

That address is the source of the DNS query, not the DNS server.

To test a particular network device, use curl’s --dns-interface option. Replace eth1 with the interface name from the system’s interface list:

curl --dns-interface eth1 -v "https://example.com/"

These options control DNS-query traffic, not necessarily the subsequent connection to the destination server. If either changes the outcome, correct the underlying routing or per-link DNS configuration, then retry without the override.

Confirm the Fix and Keep It Working

A repair is complete when the original operation works through its normal configuration, not just with a temporary DNS override.

Check that:

  • The intended hostname resolves inside the environment that previously failed.
  • The original curl command or application operation completes without an unexpected resolution error.
  • The request works without temporary proxy bypasses or --resolve entries.
  • DNS configuration survives a relevant reconnect, service restart, or workload recreation.
  • Private names still resolve through the intended VPN or internal DNS service.

An HTTP response confirms that name resolution and connection establishment succeeded for that request, even if the response reveals a separate authentication or application problem.

If the failure remains intermittent, collect the exact hostname, curl version, resolver settings, failing runtime, and sanitized verbose output. Remove authorization headers, cookies, tokens, and proxy credentials before sharing logs with the network or service owner.

Frequently Asked Questions

Why Does Curl Say It Could Not Resolve setup.runtipi.io?

The error means curl could not translate setup.runtipi.io into an IP address in the environment running the request; it does not by itself show that the service is down. Verify the hostname against the project’s current official installation instructions, then compare its lookup with a known public domain. If only that name fails across appropriate resolvers, investigate the domain’s DNS rather than repeatedly changing local settings.

Why Do I Get This Error After Installing a Wildcard Certificate?

A wildcard certificate does not create DNS records. The requested hostname still needs a valid DNS record or another supported local name mapping that points to the intended server. Fix name resolution first; certificate validation happens later in the connection.

Why Does a Website Open in My Browser but Fail in Curl?

Your browser may use secure DNS, a proxy, cached results, or a different network environment from curl. Curl therefore may not be using the resolver or route that made the browser request succeed. Compare the exact hostname, proxy configuration, VPN connection, and execution environment before changing system-wide DNS.

Why does curl try to resolve version=’1.0′ as a host?

When curl reports `version=’1.0’` as the host, compare the command with the documented case where curl reported `POST` as a host and removing that `POST` argument cleared the error. Check whether `version=’1.0’` is an unintended standalone argument.