How does /etc/hosts or /private/etc/hosts work on 10.11?
The /etc/hosts file on UNIX systems is for local DNS resolving.

As such, it doesn't take into account ports - it links hostnames with IP addresses, like the Domain Name Service.

Adding the following line:

127.0.0.1 foo

to your /etc/hosts file tells the internal DNS responder to send requests for foo to 127.0.0.1. 

It will allow you to do the following:

# curl foo:3000