无法使用端口80运行pm2进程
我有一个需要在端口80下运行的Node项目,但是在运行带有端口80的pm2项目时出现问题,我的应用程序的实例运行但是我在端口80上遇到了与EACCESS相同的可预测问题
Error: bind EACCES null:80
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at cb (net.js:1302:16)
at rr (cluster.js:594:14)
at Worker.<anonymous> (cluster.js:564:9)
at process.<anonymous> (cluster.js:714:8)
at emitTwo (events.js:92:20)
at process.emit (events.js:172:7)
at handleMessage (internal/child_process.js:689:10)
at Pipe.channel.onread (internal/child_process.js:440:11)
我做了一些研究并尝试了这里概述的the setcap approach,只是为了给节点带来这些权利(可能是因为我让node
成为nodejs
的符号链接,设置为在端口80运行):
Failed to set capabilities on file `/usr/bin/node' (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file
我试图将pm2实例作为sudo运行,但没有成功。该进程拒绝在端口80上连接。有没有更简单的方法来解决这个问题?我在配置中遗漏了什么吗?
回答如下:没有sudo,你不能在1024以下的端口号上监听。