is there a convention for localhost ports ... does it matter?

Viewed 465

I'm shocked I couldn't find the answer to this anywhere. Or I'm blind.

But is there a convention that certain localhost port numbers are used for different languages/frameworks? Or are they chosen arbitrarily?

For example I've found (generally) many javascript applications will use port 3000, but golang ones will use 8080. Of course, the applications will work on different ports but those ones are commonly chosen.

Were these ports just decided one day arbitrarily and everyone started to stick with them?

1 Answers

Were these ports just decided one day arbitrarily and everyone started to stick with them?

They pretty much are, yeah. For ports under 1024 you need special privileges (root, or cap_net_bind_service on Linux), so it's a bit inconvenient (and a security risk if you run as root, which most applications don't need to).

But other than that: it doesn't really matter. 8080 and 8000 are chosen as it's higher than 1024 (so you don't need any special privileges) and easy to memorize since the standard HTTP port is 80.

Where port 3000 comes from? I don't know. Frontend people probably wanted to avoid conflicts with backend services on 8000 or 8080, so they chose a new number, and any number above 1024 that's not already widely used will do.

Related