For Node.js applications, when to use port 3000 vs 8080?

I think both port "3000" and port "8080" are used for developing purpose in the tutorials you read, in such cases either one works well and neither is better than the other. So you can just pick one to use. However after you finish the development and want to deploy your project into production, please choose the proper port such as "80" for "http or "443" for "https" as you need.


You use port 3000 when port 8080 is used by another program on your server (maybe another node server, it is traditionally used by http proxies). Then if port 3000 and 8080 is already used you can use 3001 or 3002 or 30000 or 10000. Any unused port will do.


There isn't any official say from node.js end, as in, there aren't any official remarks pertaining to this.

You'd find many people who'd get confused that using port 80 and 443 for http and https respectively is the standard. Well this was standard for a standard PC and these details were revealed in a document released in 1994 with support of T.B. Lee.

For general network usage try not to use ports bellow 1024 as otherwise you'd have to have root access on the network server to run the process. Like the other guy said, just use any unused port and you'll be fine but above 1024 or else you'd need root access.

I'd suggest you to use any reverse proxy engine to make things more easier and suitable. Preferably nginx, they'd even help you to have multiple instances of your server which'll help you to utilize the server properly. Although it isn't necessary to make use of reverse proxy because things will work without it anyway.

I suggested reverse proxy because generally we don't make full use of the capacity of the server available to use and hence using clusters will help us to reap more performance.

Note : If you are not going to use the application in real domain and you are just trying things then please ignore the reverse proxy part, it is only important if you want to scale your application.

References

Click Here

Tags:

Port

Node.Js