跳到正文
DEV Community· Axonscape·· 3 小時前AI 評分54

部署健康檢查失敗:伺服器固定監聽 5000 埠的原因與修正方法

Deploy fails its health check: server stuck on port 5000

AI 導讀

Replit apps 監聽 5000 埠;其他主機會透過 PORT 環境變數指定應用程式使用的埠,若伺服器固定監聽 5000,便可能收不到流量,令部署逾時或健康檢查失敗。修正方法是讓伺服器監聽 Number(process.env.PORT) || 5000;文章亦提供可貼入 Lovable、Bolt、v0、Replit 或 Cursor 的提示詞,要求只修改埠設定。

正文

Axonscape

Replit apps listen on port 5000. Other hosts tell the app which port to use in PORT, so a fixed port is never reached and the deploy fails.

What you see

The build succeeds, then the deploy times out or fails its health check, and the logs say the server started on port 5000.

Why it happens

Hosts give each app a port in the PORT environment variable and send traffic there. A server hard-coded to 5000 listens somewhere nobody calls.

How to fix it

  1. Change the server to listen on Number(process.env.PORT) || 5000, and deploy again.

Or ask your AI tool to fix it

Paste this into Lovable, Bolt, v0, Replit or Cursor:

Make the server listen on the port in the PORT environment variable, falling back to 5000: Number(process.env.PORT) || 5000. Don't change anything else.


The full page, with the request ready to copy, is at launchpad.axonscape.com/fix/server-fixed-port-5000. I work on Launchpad by Axonscape, which runs a free launch check for apps built with AI tools: it finds this and the other things that break at launch, from a public GitHub repo or a .zip of the code, and keeps nothing.

來源:DEV Community · dev.to