The Squad Blog
RELATED

Editing the /etc/hosts file in OSX

Phil Tapia

Phil Tapia  Apr. 24

0 0

Pretty often at Squad we need to configure our machines for testing websites. Recently I ran into a scenario where I needed to edit my local hosts file because the DNS for a site in development had not been taken live yet. By editing my hosts file, I can trick my system into thinking the domain name resolves to an IP address, even though it really doesn’t. To do this, follow these steps.

  1. Open Terminal
  2. Type command: sudo su
  3. Enter your admin password and hit enter
  4. Now you are at root and have the permissions to edit the hosts file. To do this type: nano /etc/hosts and hit enter.
  5. Add the IP address of the system you want the domain name to point to, then hit Tab and type the domain name. You will have to do www if you also want that to work with the domain name.
  6. When finished editing, hit CTRL O to save then CTRL X to exit.
  7. Finished.

Open your web browser and open the domain name you input into your hosts file. It should be pointed at the IP you entered. If it is not, you may need to flush your DNS. If you don’t know how to do that, I’m planning to write about that in a few days.

Remember to re-edit your hosts file once the real DNS has been taken live. You don’t want to be hitting the dev server in the future when the production site is really up! That can cause some very confusing troubleshooting. Believe me!

 

Post A Comment

Sorry! Comments are closed.

Want to talk to us? Email us at info@madebysquad.com.