What is the hosts file and when do you use it?

BeginnerConceptDNS
Answer

/etc/hosts maps names to IPs locally and is consulted before DNS. We use it to test a site on a new server before changing DNS, or to pin names in an emergency.

echo "203.0.113.10 app.example.com" | sudo tee -a /etc/hosts

curl --resolve app.example.com:443:203.0.113.10 https://app.example.com does the same for one command, without editing files.

All Networking questions Roadmap: Networking for DevOps

More on DNS