Our Knowledge Base provides step-by-step guides, troubleshooting tips, and expert insights to help you manage VPS, dedicated servers, domains, DDoS protection, and more — all designed to make your experience with us fast, secure, and stress-free.
In this article, we’ll provide instructions about how to modify the hosts file on Linux, macOS, and Windows.
The hosts file is used to map domain names (hostnames) to IP addresses. It is a plain-text file used by all operating systems including, Linux, Windows, and macOS.
Entries in the hosts file have the following format:
IPAddress DomainName [DomainAliases]
The IP address and the domain names should be separated by at least one space or tab. The lines starting with #
are comments and are ignored.
To add an entry to the hosts file, simply open the file in your text editor. Below is a sample hosts file:
# Static table lookup for hostnames. # See hosts(5) for details. XX.XX.XX.XX nexonhost.desktop nexonhost XX.XX.XX.XX localhost
The hosts file changes take effect immediately except in cases where the DNS entries are cached by applications.
To undo the changes, simply open the file and remove the lines you added.
On Linux, the full path to the file is /etc/hosts.
The instructions below are valid for all Linux distribution, including Ubuntu, CentOS, RHEL, Debian, and Linux Mint:
In your terminal window, open the hosts file using your favorite text editor :
sudo nano /etc/hosts
When prompted, enter your sudo password.
Scroll down to the end of the file and add your new entries:
Save the changes.
On Windows, the full path to the file is c:\Windows\System32\Drivers\etc\hosts. The instructions below are valid for Windows 10 and Windows 8.
Press the Windows key and type Notepad in the search field.
Right-click on the Notepad icon and select Run as administrator.
In Notepad, click File then Open. In the File name field, paste c:\Windows\System32\drivers\etc\hosts.
Scroll down to the end of the file and add your new entries:
Save the changes by clicking File > Save.
On macOS, the full path to the file is /etc/hosts. The instructions below are valid for all macOS versions.
In your terminal window, open the hosts file using your favorite text editor:
sudo nano /etc/hosts
When prompted, enter your administrative password.
Scroll down to the end of the file and add your new entries:
Save the changes and flush the DNS cache:
dscacheutil -flushcache
The hosts file allows you to set the IP address of a given domain name.