You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache无法连接PM2托管的Node.js进程问题求助

Apache无法连接PM2托管的Node.js进程问题求助

各位大佬好,我在Ubuntu 20上部署了Apache,最近一直遇到连接错误,在/var/log/apache2/error.log里看到如下日志:

[proxy:error] [pid 7064] (111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:4000 (127.0.0.1) failed

[proxy_http:error] [pid 7064] [client ...] AH01114: HTTP: failed to make connection to backend: 127.0.0.1

我的虚拟主机配置是这样的:

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin me@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on

# Reverse Proxy Stuff for Node
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:4000/ Keepalive=On
ProxyPassReverse / http://127.0.0.1:4000/ Keepalive=On

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

我在网站目录/var/www/example.com下用PM2启动了Node.js应用,命令是:
pm2 start index.js -p 4000

执行pm2 status显示进程是在线状态,而且PM2日志里也没有任何错误,但Apache和PM2就是没法正常通信。

用netstat -tulpn检查后发现,根本没有进程在监听4000端口,我实在找不到问题出在哪了,有没有大佬能给点思路?

备注:内容来源于stack exchange,提问作者Clifton Labrum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 15:03:09