Edit the hosts file on Windows, macOS or Linux

The hosts file can be used to point a domain to an IP address while developing, before the DNS is configured to point to the server.


The operating system uses the hosts file to map hostnames/web addresses to IP addresses. The hosts file consists of lines with an IP address followed by one or more hostnames. By editing the hosts file on your local computer, you can make the computer resolve a specific IP address when you enter a web address.

Being able to modify the hosts file is especially useful when you are developing a website on a server in Glesys Cloud and need to test the site before the domain has been pointed to us.

In this guide, you will learn how to edit the hosts file on Windows, macOS, and Linux, and how to verify that it works.

Step 1: Open Notepad as an administrator by right‑clicking the application and selecting "Run as administrator". Without admin rights, you won’t be able to modify the file.

Step 2: Click FileOpen… (shortcut Ctrl+O).

Step 3: Type C:\Windows\System32\drivers\etc into the address bar at the top and press Enter.

Step 4: Enter hosts in the File name field. The file that opens will look something like this:

C:\Windows\System32\drivers\etc\hosts
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handle within DNS itself.
#       127.0.0.1       localhost
#       ::1             localhost 

Step 5: If you want to point the domain example.com to the IP address 192.168.1.100, write the IP address followed by the domain name:

Now the hosts file will look something like this:

Click File and then Save (Ctrl+S) to save the file.

How do I verify if it's working?

There are two ways to verify that your changes are working:

  1. Enter the address in your web browser.

  2. Ping example.com and check which IP address the ping request is sent to.

Keep in mind that you may need to clear your browser’s cache or browse to the address in a private/incognito window.

Last updated

Was this helpful?