Preparing Your Hosts file

What's a hosts file?

The hosts file maps a hostname/domain to an IP address, allowing you to visit a given domain on your browser and have it resolve by your system to the given IP address, even if it's pointed back to your own system or network.

When staging a local Site project, you may want to add an entries to your hosts file so you can visit the site with the domain http://pythondiscord.local. This is purely for convenience, and you can use localhost or 127.0.0.1 instead if you prefer.

What to add

You would add the following entry to your hosts file.

127.0.0.1   pythondiscord.local

How to add it

Linux

  1. Run sudo nano /etc/hosts
  2. Enter your user password.
  3. Add the new content at the bottom of the file.
  4. Use CTRL+X
  5. Enter y to save.

This covers most linux distributions that come with nano, however you're welcome to use whatever CLI text editor you're comfortable with instead.

Windows

  1. Open Notepad as Administrator.
  2. Open the file C:\Windows\System32\Drivers\etc\hosts
  3. Add the new content at the bottom of the file.
  4. Save.

MacOS

  1. Run sudo nano /private/etc/hosts in Terminal.
  2. Enter your user password.
  3. Add the new content at the bottom of the file.
  4. Use CTRL+X
  5. Enter y to save.
  6. Flush your DNS by running dscacheutil -flushcache