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
- No
nameserverline in/etc/resolv.conf. - A
nameserverthat 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 - 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.
- A bare machine: networking by hand : its challenge "Names that go nowhere" set the fault for you to find and fix.