WordPress MultiManager - your centralized solution for effortless management of multiple WordPress sites. Apply bulk updates, install plugins and themes, manage users, get emails about available updates, and more. Streamline your WordPress workflow now with WordPress MultiManager. It's completely free!
This tutorial will show you how to edit your local hosts file, so you can view and test a website without changing the DNS of the domain.
What is the hosts file?
The hosts file is a system file on your computer that maps hostnames to IP addresses. You can consider it your computer's local DNS. When you connect to a hostname, your computer checks for matching records in your hosts file. If no matches are found in your hosts file, your computer checks for records in the global DNS.
Editing your hosts file
To edit your hosts file, you will need to perform different actions depending on your operating system. You can find step-by-step instructions for the most widely used operating systems listed below:
Press ⊞ Win+R on your keyboard to open the Run application.
Input the following command in the Run application window:
notepad %WinDir%\System32\drivers\etc\hosts
Press Ctrl+⇧ Shift+↵ Enter to open your "hosts" file in Notepad with administrator privileges. Note: A pop-up window may appear asking you to confirm that you wish to grant administrator privileges to Notepad.
To add a new mapping to your hosts file, add a new line at the end of the file in the following format: __IP_ADDRESS__ __HOSTNAME_1__ __HOSTNAME_2__You will need to replace the variables listed above as follows:
__IP_ADDRESS__ with the IP address for your hosting account. More information on how to find your hosting account's IP address/es is available in the "IP addresses and DNS service" article.
__HOSTNAME_1__ and __HOSTNAME_2__ with your website's hostnames (i.e. your-domain.com and www.your-domain.com).
Note: You can insert a comment to the hosts file by adding a hashtag (#) character at the start of a new line or after a custom mapping followed by your comment.
Example: If your hosting account's IP address is 123.123.123.123, and your domain is your-domain.com, you will need to add this line to your hosts file: 123.123.123.123 your-domain.com www.your-domain.com
Press Ctrl+S to save your changes to the hosts file.
Go to "Finder" > "Applications" > "Utilities" > "Terminal" to open Terminal.
Input the following command in Terminal:
sudo nano /etc/hosts
Press ↵ Enter to open your "hosts" file with the GNU nano text editor. Note: Editing the "hosts" file requires administrator privileges, so you will be asked to enter your Administrator password.
To add a new mapping to your hosts file, add a new line at the end of the file in the following format: __IP_ADDRESS__ __HOSTNAME_1__ __HOSTNAME_2__You will need to replace the variables listed above as follows:
__IP_ADDRESS__ with the IP address for your hosting account. More information on how to find your hosting account's IP address/es is available in the "IP addresses and DNS service" article.
__HOSTNAME_1__ and __HOSTNAME_2__with your website's hostnames (i.e. your-domain.com and www.your-domain.com).
Note: You can insert a comment to the hosts file by adding a hashtag (#) character at the start of a new line or after a custom mapping followed by your comment.
Example: If your hosting account's IP address is 123.123.123.123, and your domain is your-domain.com, you will need to add this line to your hosts file: 123.123.123.123 your-domain.com www.your-domain.com
Press ^ Ctrl+O to save your changes to the hosts file.
Open a Terminal window. The default keyboard shortcut is Ctrl+Alt+T.
Input the following command in Terminal:
sudo nano /etc/hosts
Press ↵ Enter to open your "hosts" file with the GNU nano text editor.
To add a new mapping to your hosts file, add a new line at the end of the file in the following format: __IP_ADDRESS__ __HOSTNAME_1__ __HOSTNAME_2__You will need to replace the variables listed above as follows:
__IP_ADDRESS__ with the IP address for your hosting account. More information on how to find your hosting account's IP address/es is available in the "IP addresses and DNS service" article.
__HOSTNAME_1__ and __HOSTNAME_2__ with your website's hostnames (i.e. your-domain.com and www.your-domain.com).
Note: You can insert a comment to the hosts file by adding a hashtag (#) character at the start of a new line or after a custom mapping followed by your comment.
Example: If your hosting account's IP address is 123.123.123.123, and your domain is your-domain.com, you will need to add this line to your hosts file: 123.123.123.123 your-domain.com www.your-domain.com
Press Ctrl+O to save your changes to the hosts file.
All prices are in USD. No setup fees. Minimum contract period for shared hosting services - 12 months. Full prepayment for the contract period. 100-day money-back guarantee. No automatic renewal. Fees for domain registrations and SSL certificates cannot be refunded in case of an early contract termination.