node pm2 启动 Error: getaddrinfo ENOTFOUND 解决方法

在新的服务器上部署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.



版权声明:本文为spring21st原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。