How to Edit Hosts File

How to Edit Hosts File

  • One popular procedure for manually mapping hostnames to IP addresses on a local workstation is editing the hosts file. The hosts file may be edited using the following method on various operating systems:

For Windows:

  • Open Notepad as an administrator:

    • Right-click on the Notepad application.

    • Choose "Run as administrator."

  • Open the hosts file:

    • In Notepad, go to File -> Open.

    • Navigate to C:\Windows\System32\drivers\etc.

    • In the file type dropdown, select "All Files" instead of "Text Documents" to see the hosts file.

    • Open the hosts file.

  • Edit the hosts file:

    • Add entries in the format: IP_Address Hostname.

    • For example: 127.0.0.1 example.com.

  • Save the hosts file:

    • After editing, save the file. You may need to overwrite the existing hosts file.

  • Flush DNS cache (optional):

    • Open Command Prompt as an administrator.

    • Run the command: ipconfig /flushdns.

For macOS and Linux:

  • Open Terminal:

    • You can find it in the Applications > Utilities folder on macOS. On Linux, use the terminal application.

  • Open the hosts file:

    • Type: sudo nano /etc/hosts and press Enter.

    • You'll be prompted to enter your password.

  • Edit the hosts file:

    • Add entries in the format: IP_Address Hostname.

    • For example: 127.0.0.1 example.com.

  • Save the hosts file:

    • In Nano, press Ctrl + X, then press Y to confirm changes, and press Enter.

  • Flush DNS cache (optional):

    • On macOS, you can use the command: sudo dscacheutil -flushcache.

    • On Linux, use: sudo service nscd restart or sudo /etc/init.d/nscd restart.


BONUS: On Zeronoon, an annual hosting plan comes with a free domain. 

Click this link www.zeronoon.com/webhosting now to secure yours today at 57.1% off.
    • Related Articles

    • DNS Zone Editor- How to Edit

      The DNS Zone is the interface via which you may modify a domain that is currently hosted on your server in specified ways. You must first be logged into your hosting package's cPanel in order to use the DNS Zone Editor. The Zone Editor icon may be ...
    • How to take and share a screenshot

      In order to expedite the resolution process, you might occasionally be required to capture and share a screenshot while contacting our Customer Support Team. For instance, look at the settings on your mail client or dynamic DNS router. This post will ...
    • What Is A Cron Job?

      Cron Jobs With the help of the Linux utility Cron, users may program or automate repetitive processes to occur at predetermined periods. These are the individual jobs, or cron jobs. Here are some examples of Crons that your developer or you could ...
    • MultiPHP INI Editor in cPanel

      Making modifications to the php.ini file might occasionally be useful in order to specifically alter PHP settings for particular scripts. One unique file that can be used to easily change the server defaults for PHP settings on a particular website ...
    • Troubleshooting Email DNS with Webmail

      Of course! In order to resolve DNS (Domain Name System) problems with webmail, you must examine and confirm the different DNS entries connected to your domain. This is a step-by-step tutorial to assist you in locating and fixing any possible DNS ...