在新的服务器上部署node以后,使用pm2 作为进程管理工具,
安装完成以后,pm2 无论执行
pm2 list 还是pm2 的其它命令,全部报
Error: getaddrinfo ENOTFOUND
的错误。
仔细检查安装都没问题,上git pm2的issue搜索发现,居然是hosts的原因导致的。
默认centos的 hosts 会把本地 127.0.0.1 localhost 注释掉,去掉再试下就可以了。
参见git pm2 issue:
原解答:
My fault! My deployment scripts were accidentally deleting the
localhost from the /etc/hosts file, making it impossible to nodejs find the local machine.
本文介绍了解决PM2部署Node.js应用时遇到的“Error:getaddrinfoENOTFOUND”错误的方法。该问题源于hosts文件中localhost条目的缺失,通过恢复此条目可以解决该错误。
1万+

被折叠的 条评论
为什么被折叠?



