Scenario: you’re writing up some documentation for your HTTP library. You’ve been working on it for hours, and it is getting mind-numbingly boring. You need to provide some examples of fetching by hostname and IP address. No problem:
But what happens if someone pastes your example into their code and runs it without thinking to change the hostname/IP?
fake.com is a real website, currently selling landscaping services. And while
18.104.22.168 doesn’t seem to be serving any content right now, it’s owned by “China Unicom Beijing Province Network”, so who knows what could be served up by that IP in the future?
Safe host names (also good for URLs and email addresses):
Note that IANA actually returns a web page for example.com, example.org, and example.net. The reserved TLDs (
.invalid) do not have any full hostnames that resolve to any actual servers that I’m aware of.
Safe IPv4 addresses:
There are lots of good options for example IP addresses and hostnames. Don’t be lazy and don’t be cute: just use the reserved ones.