2 Identical IPs in Host File, Which Resolves First? - hosts

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?

Related

ERR_TOO_MANY_REDIRECTS after change .dev domain to .test in /etc/hosts for rails app

I wanted to change development domain to .test from .dev for our rails app after new Chrome update that forces https for .dev domains.
I updated all spots in the app where we were using .dev domain. I changed /etc/hosts file too. It looks like below. I get ERR_TOO_MANY_REDIRECTS error when try access the app in a browser. I see in logs that this request does not hit the app, so it probably fails somewhere earlier. Any ideas how to fix this?
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 example.test
127.0.0.1 www.example.test
127.0.0.1 app.example.test

Is there another way to demonstrate 127.0.0.1 page

I'm editing the hosts file by say adding 127.0.0.1 somesite.com
When I am navigating this site (somesite.com) access to this site will be blocked.
Can I actually edit the info which will be shown in browser when it is blocked?
127.0.0.1 is the loopback address, meaning that it will attempt to open port 80 on the local machine on which the host file resides. If you want to customize the page that is displayed then you will need to install a webserver of some variety on the same machine.

cant reach asp.net page on other server

I have defined an asp.net mvc app on server x. I added the sitename in the hostfile:
127.0.0.1 weeral.com
Also in IIS 7 i have added this as a sitebinding hostname weeral.com
When I hit http://weeral.com it responds find on the server.
However when I ping weeral.com from a different machine in the network it goes:
Ping request could not find host weeral.com. Please check the name...
what am i doing wrong?
The different machine doesn't have the same host file.
You need to map 127.0.0.1 to weeral.com on every one of the machines you use. If you used Dropbox (or something similar) you could symbolically link the machine's host file to the one in your Dropbox. I've done this for other config files, so I would think it would work for the host file.

I can't see anything while running Rails server or Node server

I'm in a big problem, I can run my Rails or Node servers, but when I look into the browser, Chrome tells me that can't acces into localhost page.
I tried modifying the hosts file in C://Windows/System32/drivers/etc/hosts
I have removed the comments to:
127.0.0.1 localhost
::1 localhost
But nothing happens, when that lines are in comments Apache works, but not Rails or Node.
I don't have any proxy, I triedd with differents ports, and I don't know what else to do.
I would appreciate any advice

Mongrel server trying to perform GET on 127.0.0.1

I've recently started a Rails 3 project which I checked out from github. The application uses subdomains to access accounts so I had to perform a small change in my etc/hosts/ file so that the app navigates properly. I'm now trying to login to the app but am seeing a very strange request in the terminal:
Started GET "/session/new" for 127.0.0.1 at Sun May 08 13:48:38
I'm using the mongrel server and its running on ip 0.0.0.0 so I can't figure out why the app is looking up 127.0.0.1. I'm on OS X so ive stopped my local apache server too.
I've removed all traces of the string "127.0.0.1" in my app but still see the request being made to that IP.
Does anyone have any idea's as to why this is happening?
EDIT: Hosts file is as following:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost ger.mpt.local
255.255.255.255 broadcasthost
#::1 localhost
#fe80::1%lo0 localhost
EDIT: I should also mention that I get a 302 redirect status from firebug when I submit the login form.
Thanks,
gearoid
Mmm. 0.0.0.0 means that Mongrel listens on every IP address "associated" with your system, including localhost (localhost is defined as an alias to 127.0.0.1 everywhere).
The answer to this lay in the session storage configuration.
After debugging through the code I could see that the session wasn't being made readily available to various authentication methods. Upon deeper inspection I found a config file which set the domain which the session is picked up from. Setting that to "mpt.local" allowed the session to get picked up and thus allowed me to login.

Resources