简体   繁体   English

Express 应用中端口 3000 的意义

[英]Significance of port 3000 in Express apps

I noticed that almost all examples of Express.js applications use port 3000 as the default listening port for HTTP servers.我注意到几乎所有 Express.js 应用程序示例都使用端口 3000 作为 HTTP 服务器的默认侦听端口。 Is this just because it's a rarely used port, or is there any other reason for this port number?这仅仅是因为它是一个很少使用的端口,还是这个端口号有任何其他原因?

If I want to run multiple apps side-by-side on my local machine, is it good practice to use ports like 3000, 3001, 3002, etc.?如果我想在本地机器上并排运行多个应用程序,使用 3000、3001、3002 等端口是一种好习惯吗?

(I understand that ideally, you'd let the system assign ports. This is just a question as a matter of simplicity, and why 3000 seems to be a conventional assignment.) (我理解理想情况下,你会让系统分配端口。这只是一个简单的问题,为什么 3000 似乎是一个传统的分配。)

3000 is a somewhat arbitrary port number chosen because it allows you to experiment with express without root access (elevated privilege). 3000是一个有点随意选择的端口号,因为它允许您在没有 root 访问(提升权限)的情况下试验express Ports 80 and 443 are the default HTTP and HTTPS ports but they require elevated privilege in most environments.端口 80 和 443 是默认的 HTTP 和 HTTPS 端口,但在大多数环境中它们需要提升的权限。

Using port 3000 in examples also helps indirectly emphasize that you ideally want to put your express app behind nginx or Apache httpd or something like that which would listen on port 80 and/or 443.在示例中使用端口 3000 也有助于间接强调您理想地希望将express应用程序置于nginx或 Apache httpd或类似监听端口 80 和/或 443 的东西之后。

There is no reason (that I'm aware of, anyway) why 3000 is better than 8000 or 4000 or 8080 or any of a number of other port numbers that are accessible without elevated privileges.没有理由(无论如何我都知道)为什么 3000 比 8000 或 4000 或 8080 或许多其他无需提升权限即可访问的端口号中的任何一个更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM