Express应用程序中端口3000的意义 [英] Significance of port 3000 in Express apps

查看:585
本文介绍了Express应用程序中端口3000的意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到Express.js应用程序的几乎所有示例都使用端口3000作为HTTP服务器的默认侦听端口.仅仅是因为它是一个很少使用的端口,还是这个端口号有其他原因吗?

I noticed that almost all examples of Express.js applications use port 3000 as the default listening port for HTTP servers. Is this just because it's a rarely used port, or is there any other reason for this port number?

如果我要在本地计算机上并行运行多个应用程序,使用3000、3001、3002等端口是否是一种好习惯?

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似乎是常规分配.)

(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是选择的某种任意端口号,因为它允许您在没有root访问权限(提升权限)的情况下尝试使用express.端口80和443是默认的HTTP和HTTPS端口,但在大多数环境中它们要求提升的特权.

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.

在示例中使用端口3000还可以间接强调您理想情况下希望将您的express应用程序放置在nginx或Apache httpd或类似的可以监听端口80和/或443的内容之后.

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比8000或4000或8080或任何其他没有提升特权的端口号要好.

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.

这篇关于Express应用程序中端口3000的意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆