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

来源:互联网 发布:ubuntu换语言 编辑:程序博客网 时间:2024/05/21 06:41

在新的服务器上部署node以后,使用pm2 作为进程管理工具,

安装完成以后,pm2 无论执行 

pm2 list 还是pm2 的其它命令,全部报


 Error: getaddrinfo ENOTFOUND

的错误。


仔细检查安装都没问题,上git pm2的issue搜索发现,居然是hosts的原因导致的。

默认centos的 hosts 会把本地 127.0.0.1 localhost 注释掉,去掉再试下就可以了。


参见git pm2 issue:

https://github.com/Unitech/pm2/issues/324 

原解答:
My fault! My deployment scripts were accidentally deleting the localhost from the /etc/hosts file, making it impossible to nodejs find the local machine.


1 0