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¶
- Run
sudo nano /etc/hosts
- Enter your user password.
- Add the new content at the bottom of the file.
- Use
CTRL+X
- 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¶
- Open Notepad as Administrator.
- Open the file
C:\Windows\System32\Drivers\etc\hosts
- Add the new content at the bottom of the file.
- Save.
MacOS¶
- Run
sudo nano /private/etc/hosts
in Terminal. - Enter your user password.
- Add the new content at the bottom of the file.
- Use
CTRL+X
- Enter
y
to save. - Flush your DNS by running
dscacheutil -flushcache