You did not define
example.dev anywhere, so how would your computer know it needs to map to your machine? I assume it is defined somewhere in your network though, and then maps to
(Likewise, domains such as
lvho.st, aka Local Virtual Host, are registered by some people who made them and al their subdomains point to
.dev is a proposed level domain. When pinging or digging it on my machine, I see:
example.dev. 3600 IN A 127.0.53.53
...where this special IP address should ring alarm bells:
127.0.53.53 is a special IPv4 address that will appear in system logs alerting system administrators that there is potential name collision issue, enabling a quick diagnosis and remediation. The "53" is used as a mnemonic to indicate a DNS-related problem owing to the use of network port 53 for the DNS service.
I don't know how it got mapped like that in my network; maybe as the
.dev domain is in a proposal state and someone already partially added it? As an aside: all
.dev domains map to that IP address for me. Still then,
127.0.53.53 does not map to my local web server.
So, I assume that
example.dev maps to
127.0.0.1 in your network, and to make your computer lookup the name, it needs a network connection. As using
.dev might clash if the proposed top level domain is ever assigned, and as you want things to work without a network connection, you could add other aliases to your host file. Like on the line for
127.0.0.1 localhost my.host www.my.host subdomain2.my.host another-host
You can see where that is going if you need many (sub)domains... To use wildcards without a network connection, you'd probably need to set up some DNS server on your local machine.
To quickly see if all this is indeed the issue, just add
127.0.0.1 localhost example.dev