Usually when binding a socket to the server, the ip binded could be any of the ips the server keeps including the loopback address, the local area network address, the public Internet address or a preserved address 0.0.0.0
.
For loopback address or 127.0.0.1
, only local connection to localhost
will be recieved. It’s useful in debugging or when using a Reverse Proxy like ngrok.
For the local area networks adress like 192.168.7.7
or public Internet address like 1.2.3.4
, only external access to the mechine will be recieved which is most of the server need.
There is an ultimate solution which is a preserved address 0.0.0.0
. It includes both three address above and any other unknown addresses. Using it makes sure that all the connections are listen.