There's more to localhost than 127.0.0.1

The loopback interface is most familiarly encountered as 127.0.0.1 and is referred to as the local loopback address. This address is present on every IPv4 host and is given the hostname localhost.

Did you know there's ~16 million other addresses that applications can also listen? This means that you can have multiple local services on the same port; as long as they are listening on a dfiferent address.

The local loopback address is not a single address,
it's the range 127.0.0.1 - 127.255.255.254.