1

I'm building a tutorial (Flask web development) that students work on using a variety of operating systems. I'm mostly an OS X user, so I obliviously configured the app host to be 0.0.0.0:5000 and then tried updating a Windows hosts file only to realise that it wasn't possible to use that IP on Windows. I've now switched it to 127.0.0.1 (localhost). My question is: Is this likely to be suitable for students on Linux? I'm just wondering if there are any other gotchas I should be aware of. Thanks in advance.

cs_stackX
  • 113
  • 3
  • By using the loop back / localhost address (IPv4 `127.0.0.1` or IPv6 `::1` ) you also ensure that the listener can’t be accessed remotely (neither by other machines in the same LAN nor from the WAN) so you can’t instruct your students to connect to and test the services developed by their lab partner sitting next to them – Bob Jan 23 '20 at 23:04

1 Answers1

4

127.0.0.1 is the universal loopback IP address. It will work on any operating system using a TCP/IP stack built after 1986.

As an aside, 0.0.0.0 is not an IP address you can bind to on any operating system. 0.0.0.0 actually means "bind to all IP addresses". So you should be able to bind to 0.0.0.0 and still access on 127.0.0.1.

A much better description of the difference between these two addresses can be found on super user here:

What's the difference between 127.0.0.1 and 0.0.0.0?

Mark Henderson
  • 68,823
  • 31
  • 180
  • 259
  • 2
    Actually, any address in the `127.0.0.0/8` block will loop back inside the host. Some programmers have used that for inter-process communication where each process has a different address in that block, but then they run into a big problem trying to convert to IPv6, which has only one loopback address (`::1`). – Ron Maupin Jan 23 '20 at 22:44
  • At least one counter example exists to all IP stacks having v4, FreeBSD can be compiled with IPv6 but without IPv4. https://people.freebsd.org/~rodrigc/doc/data/ipv6/ipv6only.html Linux can't do this, so if you are limited to Win/macOS/Linux 127.0.0.0/8 will exist. – John Mahowald Jan 23 '20 at 23:10