大网数据广告活动
服务器运维问答

AH01114: HTTP: failed to make connection to backend: localhost

· 52CE 我爱测

I know some of you might think that its a little bit off topic here, but am not sure whether its fault of server OR fault of my config file, so... I made React.js project , but it needs server side rendering, So now I have to mig…

问题原文

原帖链接 · Y U K I M U R A · CC BY-SA 4.0

I know some of you might think that its a little bit off topic here, but am not sure whether its fault of server OR fault of my config file, so...

I made React.js project , but it needs server side rendering, So now I have to migrate from CRA to next.js . the problem: I have to upload my website on apache web server, from what I gathered from google, I need installed node.js and pm2 (latest versions), also configured apache for reverse proxy. I also created ecoystem for pm2(I guess it was necessary). it looks like this at the moment:


module.exports = {
  apps : [{
    name: "nextjs-app",
    script: "npm",
    args: "run build",
    env: {
      NODE_ENV: "production"
    }
  }]
};

but when I ran pm2 start npm -- start , terminal is giving me respone like this:

pm2 start npm -- start
[PM2] Spawning PM2 daemon with pm2_home=/home/georgianar/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /usr/local/bin/npm in fork_mode (1 instance)
[PM2] Done.

but when I try to see list of process, there is none, and when user tries to enter the website, site log shows that there is no service on port 3000

AH01114: HTTP: failed to make connection to backend: localhost

and

(111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:3000 (localhost:3000) failed

so, am not sure its fault of server or its my config file causing this chaos. any ideas?

已采纳解答

原帖链接 · Basant Mandal · CC BY-SA 4.0

First make sure the following commands exists in your package.json

"scripts": {
    "start": "next start -p 3000"
  }

Use the following command

pm2 start yarn --name "nextjs-app" --interpreter bash -- start

You can print out detail process information using

pm2 show nextjs-app

Configure PM2 to Start on Server Boot, run the below command as root

pm2 startup

Save the pm2 process list to relaunch them after a server reboot

pm2 save

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-02-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。