I have been reading up on some tutorials, and although most of them use port 3000
for node applications. Some of them use port 8080
instead. I am wondering what is the recommended practice, and under what circumstances should we use the other. Any guidelines?
3000 is a somewhat arbitrary port number chosen because it allows you to experiment with express without root access (elevated privilege). Ports 80 and 443 are the default HTTP and HTTPS ports but they require elevated privilege in most environments.
BitTorrent Sync (BTsync) uses port 3000 UDP to connect to torrent trackers. It also uses another configurable random UDP listen port (and/or UPnP). Trend Micro Antivirus products may use port 3000 UDP to communicate with their servers.
What is port number 8080 used for? Port number 8080 is usually used for web servers. When a port number is added to the end of the domain name, it drives traffic to the web server. However, users can not reserve port 8080 for secondary web servers.
How do you check what is running on port 3000 in Windows? Open a CMD window in Administrator mode by navigating to Start > Run > type cmd > right-click Command Prompt, then select Run as administrator. Use the netstat command lists all the active ports. To kill this process (the /f is force): taskkill /pid 18264 /f.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With