Here I am running an application on a computer, host=localhost, the application runs on localhost:5000, or

  1. When the computer accesses, or subnet mask, does it refer to itself somehow? That is, I enter into the browser and since it corresponds to the mask, it refers to itself and receives a response from itself?
  2. If you put host=, it says that the application is running on a host that is in the local network. That is, before it was launched on the host, and now it is launched on, for example, the address, subnet mask Why if host=, it starts referring to the local IP address, and not to And also, it turns out that inside his subnet I will refer to his local IP address, and outside this subnet to the public one? That's what I was thinking, why if it runs on, then for devices on his subnet they will connect on his local IP, but I connect to it using his public IP, since I'm not on his subnet?
  3. I don't quite understand how the subnet mask works. For example, in the example everything is clear, there are 24 units and they will give 192.168.0, and under the last octet will be values from 0 to 255, that is, fix the first three octets, and the last octet is completely free.But if, there are 16 units, then 5 units, remains then 3 zeros and 8 zeros, as a result, the subnet mask will be and the values will be between to Now I will try to figure out the same logic - 16 units, so the first two octets remain the same, then there are 5 units and one unit in 11, that is 00001011 in binary, is left with one unit and remains 00001000 and the values will be from 00001000 to 00001111. But I am surprised that for the values will be from to, that is completely different addresses, and I thought that they will be in the same subnet with
  • 2 is a special address (IN_ADDR_ANY) used to specify "use any assigned address(es)" When you enter, you're telling the application to bind that specific address. is not valid as a destination - you can't use that in a URL.
    – Ricky
    Commented May 3 at 2:47

1 Answer 1


Localhost usually points to which is the first address of the virtual loopback interface (always connected, infinite bandwidth) with the subnet and address range It means (only) this host. cannot be routed or accessed via a physical interface. (in this context, when binding a service) is the unspecified address, essentially meaning any address on any interface on this host. That address cannot be used in any other way, neither as source nor as destination in an actual packet.

In a nutshell, binding a service to makes it accessible from this host only. Binding to makes it accessible on any IP address on any interface, physical or virtual.

For the subnet mask question, please refer to How do you calculate the prefix, network, subnet, and host numbers?

Public and private IP addresses are yet another thing. RFC 1918 defines the ranges, and to be used in private networks only. You can use any of them in any way you like, but you can't use them for communication over the public Internet, without translation or tunneling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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