0

If I have in my hosts file

127.0.0.1 localhost

then at a later line I also have

127.0.0.1 www.dev-environment.com

1. Which takes priority/resolves first?

2. What issues could I run into?

Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75
  • 1
    To have to worry about that, you would need a way to put two URLs into a browser bar at the same time. Otherwise, if it is a programming-related question, what are you using to do the reverse lookup? – Andrew Morton Jun 12 '18 at 15:24
  • Hello Andrew, right now most computers at my company have 127.0.0.1 pointed to localhost of course. But we need to switch it to dev envrionment for a docker-compose setup, so I'm wondering if writing a script to add that line at the end will take priority over the localhost one. Any thoughts? – Kevin Danikowski Jun 12 '18 at 17:05
  • 1
    localhost *must* be set to 127.0.0.1 or else all sorts of things will break by default. There is no problem with adding other entries with the same IP address. – Andrew Morton Jun 12 '18 at 17:44
  • thanks Andrew, any idea which host the IP will choose first? the first or last in the file? – Kevin Danikowski Jun 12 '18 at 18:39
  • 1
    It translates the text to the IP address, not the other way round. Are you saying that you want two entries for, say, www.example.com with different IP addresses? – Andrew Morton Jun 12 '18 at 19:28
  • oh, so both `localhost` and `www.dev-legacy.com` will resolve to `127.0.0.1`, is this correct? – Kevin Danikowski Jun 12 '18 at 19:39
  • 1
    Yes. That is also (part of) how more than one web site can exist at the same IP address using [host headers](https://stackoverflow.com/questions/43156023/what-is-http-host-header). – Andrew Morton Jun 12 '18 at 20:29

0 Answers0