There's more to localhost than

The loopback interface is most familiarly encountered as 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 -