How do you edit a hosts file on Windows or Mac?

Procédure

What is the hosts file?

A hosts file allows you to associate a host name or domain name with an IP address. Changes made to this file take effect immediately after the modification. This file is available on all operating systems.

I. Things to know before modifying the Hosts file on your computer

The Hosts file is intended to make your computer believe that your domain name points to a specific hosting account, so this does not cause any malfunction of your domain name or your website on its current hosting. You will be the only one to see the changes. Other visitors will see your website on its current hosting.

Setting up a configuration in the hosts file may require clearing the browser cache files after each change so that everything works perfectly and you can view your site on LWS or on its current hosting.

Your domain not yet actually pointing to your LWS hosting, the SSL certificate cannot be installed and you will probably have to ignore your browser's security warnings. Do not worry, once your domain redirects to our hosting, the certificate will be functional and your domain secured in HTTPS.

II. What settings should I enter in my Hosts file.

The configuration line to add to a Hosts file is as follows:
XXX.XXX.XXX.XXX domain.tld www.domain.tld

XXX.XXX.XXX.XXX is the IP address of the web server for your package at LWS, so you will need to replace this with the actual IP address of the LWS server.

domain.tld is a generic placeholder for your domain name; you will need to replace it with your real domain name.

This entry in the Hosts file is used to tell your browser that the domain you entered (with or without www) points to the IP you indicated and not the usual IP.

To find out the IP to enter, we invite you to follow this documentation. Only the WEB service IP is required.

III. How do I modify a hosts file on Windows?

A. Manual procedure

The hosts file is located at the following path:

C:\WINDOWS\system32\drivers\etc\hosts

1. The first thing to do is open a text editor such as Notepad or Word, in administrator mode (right-click then run as administrator).

2. Once the text editor is open, go to File -> Open and browse to the hosts file (C:\WINDOWS\system32\drivers\etc\hosts).

3. Then insert the hosts line you want to add: for example: 4.39.504.987 monsite.com www.monsite.com

Once this is done, your file should look like this:

 Copyright (c) 1993-1999 Microsoft Corp.                 
#                 
# This is an example of a 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. They are indicated by the                 
# symbol '#'.                 
#                 
# For example :                 
#                 
#      102.54.94.97     rhino.acme.com          # source server                 
#       38.25.63.10     x.acme.com              # x client host                 

127.0.0.1    localhost 
4.39.504.987 monsite.com www.monsite.com 

4. Then save the modification.

This modification takes effect immediately.

B. Using Microsoft's PowerToys utility

1. Go to the download page for Microsoft's PowerToys utility available on their Store.

2. Then click on "Install"

How do you edit a hosts file on Windows or Mac?

3. Click the "Install" button again in the window that will then appear

How do you edit a hosts file on Windows or Mac?

4. Once the application is installed, open it and select "Hosts File Editor" in the left menu.

How do you edit a hosts file on Windows or Mac?

5. Then click on the "Launch Hosts File Editor" button

How do you edit a hosts file on Windows or Mac?

6. A warning message will appear. You must accept this message to continue.

How do you edit a hosts file on Windows or Mac?

7. Then click on "+ New entry" ...

How do you edit a hosts file on Windows or Mac?

... and enter the desired settings before clicking on "Add".

How do you edit a hosts file on Windows or Mac?

You will then only need to leave the option enabled to view your site on LWS, or disable it to view it on the current hosting provider.

How do you edit a hosts file on Windows or Mac?


IV. How do I modify a hosts file on Mac?

1. Open Terminal

Open the MAC search tool « Spotlight » using the command:

Code
CMD + SPACE

How do you edit a hosts file on Windows or Mac?

2. Open the Mac Hosts file via the terminal

Once your terminal is open, type the following command line:

Code
sudo pico /etc/hosts

then press ENTER

Enter your Mac session password.
/!\ It will not appear in the terminal, type your password in full and press ENTER

3. Modify your Hosts file

Make the necessary changes inside your hosts file using the arrow keys on your keyboard.

How do you edit a hosts file on Windows or Mac?

4. Save your changes

To save your changes and exit the application, follow the commands below:

CTRL+O (^O) to save your changes then click on « ENTER ».
CTRL+X (^X) to exit the hosts file. You can close the « terminal » application.

All you need to do now is exit your terminal. The hosts file has been modified on your Mac.

Conclusion

You are now able to modify a Hosts file on Windows or on Mac with LWS. You can modify and/or delete the Hosts file at any time.

Feel free to share your comments and questions!

help.lws.net/a/826
Was this article helpful?

Yes

No

Read 53 242 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

Questions about the article 1

Ask a question
Alexandro
8 Jun 2024
ne fonctionne pas comme cela est dit pour Mac
Jordan-LWS Official answer
10 Jun 2024

Bonjour,

Je vous remercie pour votre message.

Je suis désolé que vous ne soyez pas en mesure de modifier votre fichier hosts correctement. Si vous souhaitez tenter une alternative, je vous invite à essayer ce site internet qui devrait répondre à vos besoins.

Suivez ces quelques étapes une fois sur le site internet :

  1. Dans Preview, laisser par défaut (the regular website)
  2. Ajouter l'adresse IP de votre serveur web dans le champ de hosted on, IP que vous pouvez retrouver directement en suivant notre documentation
  3. Dans le champ under saisissez votre nom de domaine
  4. Laisser par défaut le champ over
  5. Valider avec Go

Je vous remercie pour votre attention et reste à votre disposition pour toute autre question ou complément d'information.

Cordialement, L'équipe LWS

Was this answer helpful?

A question about this article?

Ask the LWS team and the community. Answers are published after moderation.

Ask the LWS team and its community a question

GDPR: Controller: LWS-Ligne Web Services. Purpose: moderation and public publication of your question, possible notification of an answer. Legal basis: consent (Art. 6(1)(a) GDPR). Email retention: 90 days after notification, 12 months maximum without an answer. To exercise your rights, see the GDPR section of our Terms and Conditions.