Nginx redirect me to a real site web not my virtual site

Posted March 18, 2021 238 views

Hi , it te first time that i use nginx ! so i’m asking why if i add a virtual domain name in /etc/host for exemple
and i follow this tuto but it doesn’t work :(
cna someone help me ??

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers


If you had opened in your web browser before you modified your /etc/hosts file, then it is very likely that your web browser cached site’s content and respond with such cache content to each next request sent to What I can suggest is to clear browser’s cache and try again then.

Let us know if it helps.

Hi yannek !!
no a did not open the browser before !! and it’s the same think …
even when i test a domaine name inexsisted for exemple it doesn’t work :(

  • Some tips:

    1. Check if you have not misspelled hosts file name, and what rights are set up for /etc/hosts file. Run the command:

    sudo ls -la /etc/host*

    You will get the result like below. The hosts file is highlighted. Everyone should have right to read this file.

    -rw-r--r--. 1 root root 9 Jun 7 2013 /etc/host.conf -rw-r--r--. 1 root root 22 Apr 10 2017 /etc/hostname -rw-r--r--. 1 root root 158 Mar 18 23:23 /etc/hosts -rw-r--r--. 1 root root 370 Jun 7 2013 /etc/hosts.allow -rw-r--r--. 1 root root 460 Jun 7 2013 /etc/hosts.deny

    2. To check quickly if changes in hosts file work, you can ping the host you entered in hosts file, e.g. in my case:


    I get the result like that:

    PING ( 56(84) bytes of data.

    because my hosts file looks like that:

    /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

    Try to ping a host you entered into your hosts file and let us know how it works.

    BTW. Domain exists ;-)