8

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.)

5

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.

| improve this answer | |
4

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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