Next.js Discord

Discord Forum

Why is the port 5000 causing status "errored" and port 3000 not in PM2?

Unanswered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
I am unable to make Next.js work with PM2 using port 5000:
module.exports = {
  apps: [
    {
      name: "application",
      script: "./node_modules/next/dist/bin/next",
      exec_mode: "cluster",
      instances: "max",
      args: "start",
      env: {
        NODE_ENV: "production",
        PORT: 5000
      },
    },
  ],
};

It will start but errored out in like 5 seconds after many attempts to restart instances.

When I change the port to 3000:
module.exports = {
  apps: [
    {
      name: "application",
      script: "./node_modules/next/dist/bin/next",
      exec_mode: "cluster",
      instances: "max",
      args: "start",
      env: {
        NODE_ENV: "production",
        PORT: 3000
      },
    },
  ],
};

Everything works fine and instances in cluster mode stand green "online" when doing pm2 list even after a long time.

Why is that?

0 Replies