etc/hosts entry is ignored by my amazon EC2 Ubunut instant

qbq asked:

I want to add an entry for a website name to be redireected to another website. So I added the entry in the etc/hosts file. For example, let Google’s IP is 1.2.3.4 and I want to example.com to be resolved to Google’s IP. so I added:
example.com 1.2.3.4

But this is totally ignored. When I enter example.com in an updated Chrome browser, the browser goes to example.com and ignores the hosts entry for example.com.

The experiment is successful in my own PC but does not work in my Amazon EC2 instant.

Can you explain why etc/hosts entry is ignored by my Amazon EC2 instant? How to fix this issue please?

My answer:


You’ve entered them in reverse. The IP address must come first, then the host names.

For example:

203.0.113.187 example.com www.example.com

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.