#hosts文件中添加
127.0.0.1 localhost
保存,使用命令刷新生效即可。
在新的服務(wù)器上部署node以后,使用pm2 作為進程管理工具,
安裝完成以后,pm2 無論執(zhí)行
pm2 list 還是pm2 的其它命令,全部報
Error: getaddrinfo ENOTFOUND
的錯誤。
仔細檢查安裝都沒問題,上git pm2的issue搜索發(fā)現(xiàn),居然是hosts的原因?qū)е碌摹?
默認centos的 hosts 會把本地 127.0.0.1 localhost 注釋掉,去掉再試下就可以了。
參見git pm2 issue:
[https://github.com/Unitech/pm2/issues/324](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.