Update DNS on local machine for development
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:
- 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”.
- 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”.
- 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:
- Save the hosts file and close the text editor.
- 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: 126.96.36.199 www.website.com.au
- CONTROL X
- ENTER – to close terminal