Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

node.js

port

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?

like image 306
Grateful Avatar asked Aug 24 '16 07:08

Grateful


People also ask

Why is port 3000 used when running a node JS application?

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.

What service runs on port 3000?

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 the port 8080 used for?

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.

Which of the following is used to find if port 3000 is in use?

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.


2 Answers

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.

like image 124
gangmax Avatar answered Oct 30 '22 17:10

gangmax


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

like image 34
Gandalf the White Avatar answered Oct 30 '22 16:10

Gandalf the White