Update DNS on local machine for development

February 10, 2023


To update the DNS settings on your local machine to reach a development site hosted on another server, you’ll need to add an entry to your machine’s hosts file. The hosts file is a simple text file that maps domain names to IP addresses and is used by your operating system to resolve domain names before querying a DNS server.

Here’s how you can update your hosts file:

  1. Open a text editor with administrative privileges. On Windows, you can open Notepad as an administrator by right-clicking on the Notepad shortcut and selecting “Run as administrator”. On macOS and Linux, you can use a text editor such as “nano” or “vi”.
  2. Open the hosts file. On Windows, the hosts file is located at “C:\Windows\System32\drivers\etc\hosts”. On macOS and Linux, it’s located at “/etc/hosts”.
  3. Add an entry to the hosts file for your development site. The entry should consist of the IP address of the server hosting the development site, followed by one or more space-separated domain names. For example:
192.168.1.100 mydevsite.local
  1. Save the hosts file and close the text editor.
  2. Flush your local DNS cache. On Windows, you can do this by opening a command prompt and running the command ipconfig /flushdns. On macOS and Linux, you can run the command sudo killall -HUP mDNSResponder.

Once you’ve made these changes, you should be able to access your development site using the domain name(s) you specified in the hosts file, without having to modify the DNS settings of your local machine or the server hosting the development site.

Keep in mind that the hosts file only affects the resolution of domain names on your local machine. If you need to access your development site from other machines, you’ll need to update the hosts file on each of those machines as well.

STEPS ON A MAC

  • Open terminal
  • Type: sudo nano /etc/hosts 
  • Enter Your Machine Password
  • Enter IP and Domain: 101.0.100.100 www.website.com.au
  • CONTROL X
  • Y
  • ENTER – to close terminal