Fixes

Fix

Could not resolve host, but the IP address works

The machine has no working DNS server: /etc/resolv.conf is empty or names a server that does not answer. Put a reachable resolver in it.

Likely causes

  1. No nameserver line in /etc/resolv.conf.
  2. A nameserver that is down, unreachable, or refuses your network.

Diagnose

Run these in order. The output is what each printed on a lab's real Linux machines.

laptop:~# curl -sS -m 5 http://webServer.lab/
The name fails: Could not resolve host. curl never tried to connect.
curl: (6) Could not resolve host: webServer.lab
laptop:~# ping -c1 -W1 10.0.2.10
The same server by address answers, so the network is fine and only names are broken.
PING 10.0.2.10 (10.0.2.10) 56(84) bytes of data.
64 bytes from 10.0.2.10: icmp_seq=1 ttl=63 time=0.154 ms

--- 10.0.2.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.154/0.154/0.154/0.000 ms

Fix

/etc/resolv.conf on laptop
One line names the DNS server: here the router, 10.0.1.2.
nameserver 10.0.1.2
laptop:~# curl -sS -m 5 http://webServer.lab/
The page loads by name.
hello from webServer

Break it and fix it yourself

Each lab is a small network of real Linux machines in your browser, where this fault happens.

Open A bare machine: networking by hand

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start this lab, free