Curl Error (6): Couldn't Resolve Hostname

Abstract: Fixes curl error 6 in WSL 1 by resolving DNS failures caused by empty or incorrect resolv.conf configuration.

Created: 2026-10-02 by

The "curl error (6): couldn't resolve hostname" in WSL 1 is a known limitation caused by how Windows 10 handles DNS resolution for the legacy subsystem. Unlike WSL 2, which has its own virtual network adapter and DHCP client, WSL 1 shares the host's network stack directly but often fails to inherit the correct DNS server configuration from the Windows interface. This results in an empty or incorrect /etc/resolv.conf file within the Linux environment, preventing any domain name lookups from succeeding.

Understanding the Root Cause

The fundamental difference between WSL 1 and WSL 2 dictates why this specific error occurs. WSL 2 utilizes a lightweight utility VM with a NAT network, allowing it to manage its own networking settings independently of the Windows host’s primary interface. In contrast, WSL 1 operates as a translation layer that runs directly on the Windows kernel. While this provides better performance for certain I/O operations, it creates a dependency on the Windows host’s network configuration being perfectly mirrored in the Linux filesystem. In modern versions of Windows 10 and 11, Microsoft changed how DNS servers are exposed to WSL 1 instances. Previously, the /etc/resolv.conf file was automatically generated to include the DNS servers assigned to your active Windows network adapter. However, due to changes in the Windows networking stack, this automatic population often fails, leaving the file empty or pointing to invalid addresses. When curl attempts to resolve a URL like google.com, it queries the nameserver specified in this file. If the file is misconfigured, the query times out, resulting in the critical error code 6. This issue is distinct from general connectivity problems. You can often ping IP addresses directly (e.g., ping 8.8.8.8) successfully because ICMP packets do not require DNS resolution. The failure is isolated strictly to name resolution. For more context on general internet connectivity issues in Linux environments, you might find Troubleshooting: Cannot Connect to the Internet helpful, although the underlying mechanism here is specific to the WSL 1 architecture.

Verifying the Current Configuration

Before applying fixes, you must confirm that the DNS configuration is indeed the culprit. Open your WSL 1 terminal and check the contents of the resolv.conf file. Run the following command:
cat /etc/resolv.conf
If the output is empty, contains only comments, or lists IP addresses that are not valid DNS servers for your network, you have confirmed the problem. You can also test resolution manually using nslookup or dig. If these commands hang or return "server failed" errors while ping works, the diagnosis is solid. Note that editing this file directly is usually ineffective because WSL 1 regenerates it upon every restart, overwriting any manual changes. Therefore, the solution must address the source of the configuration rather than the symptom.

Solution 1: Manually Set DNS Servers

Since the automatic generation process is broken in many WSL 1 installations, the most reliable workaround is to manually populate the /etc/resolv.conf file with public DNS servers. Google Public DNS and Cloudflare DNS are widely available and highly reliable for this purpose. First, open the file with elevated privileges using a text editor like nano or vim. You may need to use sudo if your user account does not have write permissions to system files, although typically WSL users have access to their home directory.
sudo nano /etc/resolv.conf
Delete any existing content in the file and add the following lines. These specify Google’s primary and secondary DNS servers:
nameserver 8.8.8.8
nameserver 8.8.4.4
Save the file and exit the editor. Immediately test your connection by running:
curl https://www.google.com
If the command returns HTML content or redirects without error, the issue is resolved. Be aware that this change is not persistent across reboots in the same way a static configuration would be in a traditional Linux distribution. You may need to reapply this fix after significant Windows updates or if WSL detects a change in the host network state. To make this easier, you can create a simple alias or script in your .bashrc that reapplies these settings automatically.

Solution 2: Upgrade to WSL 2

While the prompt specifically addresses WSL 1, it is important to note that Microsoft has deprecated WSL 1 for new development scenarios. The networking limitations described above are inherent to the architecture of WSL 1 and cannot be fully patched by configuration tweaks alone. WSL 2 resolves this entirely by providing a full Linux kernel inside a Hyper-V virtual machine, complete with its own DHCP client and network interface. If you are able to upgrade, you can convert your existing WSL 1 distribution to WSL 2 using the PowerShell command:
wsl --set-version Ubuntu-20.04 2
Replace Ubuntu-20.04 with the name of your specific distribution. Once converted, the DNS resolution will work out-of-the-box because WSL 2 manages its own network stack. This is the long-term recommended solution for any developer facing persistent networking issues in WSL 1. For those interested in similar troubleshooting steps for other Linux distributions, see Kali Linux: Troubleshooting Temporary Failure in Name Resolution, as the principles of fixing resolv.conf are largely identical.

Solution 3: Check Windows Network Adapter Settings

In some rare cases, the issue stems from Windows itself not correctly assigning DNS servers to the active network interface. If you are on a corporate network or using a custom VPN, the DNS settings might be restricted or blocked from propagating to WSL 1. Open the Windows Settings app and navigate to Network & Internet > Status > View your network properties. Check the IPv4 DNS Servers section. Ensure that valid IP addresses are listed. If they are blank, you may need to manually configure them in the adapter settings via the Control Panel. After updating Windows network settings, restart the WSL instance completely by running:
wsl --shutdown
Then restart your WSL session. This forces WSL 1 to re-query the Windows host for the current network configuration. If the Windows adapter now has valid DNS entries, WSL 1 should ideally pick them up, though this behavior is inconsistent across different Windows builds.

Frequently Asked Questions

Why does ping work but curl fail?

Ping uses ICMP packets which communicate directly via IP addresses, bypassing the need for domain name resolution. Curl requires a DNS lookup to translate a domain name like "example.com" into an IP address before it can connect. If the DNS resolver is broken, the lookup fails, but the raw network path remains intact.

Will editing resolv.conf persist after a reboot?

No, in WSL 1, the /etc/resolv.conf file is often regenerated or overwritten when the WSL instance starts or stops. Manual edits will be lost unless you automate the process using a startup script or alias in your .bashrc profile to rewrite the file each time you open a terminal.

Can I use wslconfig to fix this in WSL 1?

No, the [wsl2] section in the .wslconfig file applies exclusively to WSL 2. WSL 1 does not support custom network configurations through this file because it relies entirely on the Windows host’s networking stack. Attempting to configure DNS via .wslconfig in WSL 1 will have no effect.

How do I check my current DNS servers in Windows?

You can view your active DNS servers by opening Command Prompt and running ipconfig /all. Look for the "DNS Servers" entry under your active network adapter. These are the addresses that WSL 1 attempts to use, but often fails to read correctly.

Is upgrading to WSL 2 difficult?

Upgrading is straightforward and reversible. You can use the wsl --set-version command to convert your distribution. Most applications and tools work identically, though you may notice slight differences in file system performance depending on whether you are accessing files from within WSL or from Windows.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More