PM2和Nginx:502错误网关 [英] PM2 and Nginx: 502 Bad Gateway

查看:443
本文介绍了PM2和Nginx:502错误网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将我的Node项目部署在一个全新的DO Drop上,但是PM2出现了一些问题.

I've been trying to deploy my Node project on a brand new DO droplet, but i'm having some problems with PM2.

我的步骤如下:

  1. Node已安装在Droplet映像上(Ubuntu,Node v4.4.4)
  2. 在全球范围内安装了PM2
  3. 将Nginx设置为反向代理127.0.0.1:3000
  4. 克隆了我的项目并进行了npm安装

我所得到的就是Nginx抱怨502 Bad Gateway.

All i get is Nginx complaining about a 502 Bad Gateway.

如果我查看Nginx error.log,我会得到:

If i look at the Nginx error.log i get this:

connect()失败,但无法连接(111:连接被拒绝) 上游,客户端: client.ip ,服务器: my.server ,请求: 上游的"GET/HTTP/1.1":" http://127.0.0.1:3000/",主机: " 我的服务器 "

connect() failed (111: Connection refused) while connecting to upstream, client: client.ip, server: my.server, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "my.server"

PM2没什么可说的. pm2日志中没有任何内容,状态为在线.

PM2 doesn't have much to say about anything. Nothing in pm2 logs and status is online.

我尝试跳过PM2并仅执行npm start,效果很好.我还尝试设置一个虚拟的hello world应用程序,并将其与PM2一起使用-也可以.

I tried skipping PM2 and just doing npm start which worked perfectly. I also tried setting up a dummy hello world application instead, and using that with PM2 - it also worked.

所以我现在在这里:

  • 我的项目+ PM2:不起作用.
  • 我没有PM2的项目:有效.
  • Hello World应用程序+ PM2:有效.

我不太确定从这儿去哪里.我可以跳过PM2并使用node,但是我确实想要PM2的功能.

I'm not really sure where to go from here.. I could just skip PM2 and use node, but i do want the features of PM2.

有什么想法吗?

推荐答案

我只需要使用 bin/www 而不是 app来启动PM2 .js . Express生成器和所有内容...

I just had to start PM2 with bin/www instead of app.js. Express generator and everything...

这篇关于PM2和Nginx:502错误网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆