Convention about the standard port for testing and developing in node.js

node.js

I'm trying to get started with node.js.

For example en Java and .net programmer often use the port 8080?
Is there a convention like that in node.js?

I know that any port above 1024 will do it but I will like to follow the conventions so working with other programmers would be easier.

I heard that it is Ryan Dahl's (the creator of node.js) favorite port.
Where can I find what is his favorite port?

Best Answer

The traditional web server port is 80. However, this is a port in the privileged area on many systems (requiring the administrator of the machine to run the program that listens to that port).

This rules out 80 and 800 as options for ports to set up a server on. The next value in that series would be 8000. Many web servers are configured to listen on port 8000 (or the developers just use that as a convention - more on this below). Some go to 8080, or 8888 for their development port areas, but 8000 is the next value in the series. The key bit being that they are unique. You can't have two different programs both listening to the same port.

Tomcat happens to have its configuration files shipped to listen on port 8080 - though this may have changed with other version. This may be because some web developers are also running an apache httpd server on port 8000 (I've occasionally run that configuration myself - it's not uncommon) as part of the technology stack in use.

That the default configuration of a program that responds to web requests listens on port 8000 should be no surprise at all and is a convention for development servers that dates back since at least when I fired up NCSA HTTPd on port 8000 on a machine I didn't have root on.

This is a convention for development web servers or things you don't want root running (application servers vs a slim httpd proxy) and is unlikely related to any developer's favorite numbers. It's a port. It's a convention for developers that long predates Node (or even Javascript).

Related Topic