Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I see same url with localhost as remote server don't worked and with 127.0.0.1 worked or vice versa.

I want difference between four form of server indicator in url address:

  1. localhost
  2. 17.0.0.1
  3. computer name
  4. ip

for sample Apache ActiveMQ web console url can shown as following forms in my computer:

  1. http://localhost:8161/
  2. http://127.0.0.1:8161/
  3. http://mjm:8161/
  4. http://192.168.20.92:8161/

(Sorry if I am using the wrong terminology or grammar, I am learning english language.)

share|improve this question

2 Answers 2

up vote 1 down vote accepted

It is all about address resolution.

Usually, http://localhost:8161 will access http://127.0.0.1:8161. When you make the request to localhost, before making the DNS request, your OS will look at a HOSTS file (/etc/hosts in Linux) and will see there a rule that says that localhost maps to 127.0.0.1.

Sometimes, localhost is mapped to a different IP, such as 127.0.1.1. This may cause the malfunction between localhost and 127.0.0.1. (eg. your service is configured to listen to localhost which is mapped to 127.0.1.1 and you try to access 127.0.0.1).

If you use a hostname, your OS may go further on the network stack, and may even make a DNS request to discover the host IP and then try to access that URL.

When you use the IP address your SO will try to access that URL using the given IP address.

share|improve this answer

Not quite sure if I get the question, but are you wondering what the diffrence between the 4 urls are?

If that is the case:

127.0.0.1 (loopback IP for the local machine) localhost (resolves to the 127.0.0.1 address)

^ the two above, are not accessible from other equipment in your network (other workstations++)

mjm and 192.168.20.92 is in this case two ways of connecting to the same computer, accesible from the "outside".

If you want to connect to your Apache ActiveMQ from a diffrent workstation; computername or the 192.* IP would be the way to go.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.