Editing Your hosts File

This is a free resource from my online course, From Idea To Launch, where I teach you how to build a full Laravel web application, step by step, at beginner's speed. Learn more →

When you need to register a new URL — to make your computer aware it exists — you need to add a new entry for it to your computer’s hosts file.

Editing the hosts file can be a bit tricky, but follow these steps and you’ll be just fine.


On a Mac

  1. Open Finder and in the main menu, select Go > Go to Folder….
  2. Enter /private/etc/hosts and click “Go”.
  3. In that folder, you should see a file named hosts highlighted. Copy that item and Paste it on your Desktop.
  4. Open the hosts file on your Desktop in TextEdit.
  5. Add a new entry, such as the one below, to the bottom of the file and save the changes. (And you can then close TextEdit.)
    
    127.0.0.1  new-url.local
    
  6. Now copy that updated file on your Desktop, and then, back in Finder, to paste the updated file back into that same /private/etc folder, and click Replace to overwrite the existing file and entering your password. (If prompted, press the “Authenticate” button.)

In Windows

  1. In Windows Explorer, browse to the C:\Windows\System32\drivers\etc folder.
  2. In that folder, you should see a file named hosts. Copy that file to your Desktop.
  3. Open the copied file on your Desktop in Notepad.
  4. Add a new entry, such as the one below, to the bottom of the file and save the changes. (And you can then close Notepad.)
    
    127.0.0.1  new-url.local
    
  5. Now copy that updated file on your Desktop , and then, back in Windows Explorer, go to Edit > Paste Item to paste the updated file back into that same etc folder.
  6. Click Copy and Replace in the resulting popup window and then click Continue when prompted with the “You’ll need to provide administrator permission to copy to this folder” message.