Next.js Discord

Discord Forum

Next server has multiple process in ubuntu during development

Unanswered
Broad-snouted Caiman posted this in #help-forum
Open in Discord
Broad-snouted CaimanOP
I'm a developer, and I've been running a Next.js server. While running it, I noticed multiple processes of the same Next.js server. Is this common, and why is this happening? I have attached the screenshot below.

5 Replies

Rose-breasted Grosbeak
Did you use pm2?
Next.js may spawn multiple processes during development, especially when running in a clustered or hot-reloading environment. To manage this efficiently, you can use PM2, a process manager for Node.js applications. First, install PM2 globally using the command npm install -g pm2. Then, create an ecosystem.config.js file in your project root and configure it according to your needs. For example, you can define your app with multiple instances using cluster mode. Once the file is set up, start your Next.js server with pm2 start ecosystem.config.js. Additionally, configure your hosting server with PM2 to ensure your application runs smoothly. To make sure PM2 restarts the process after a reboot, run pm2 save and pm2 startup. This approach helps prevent multiple unexpected instances and ensures efficient process management for your Next.js server.
before that kill all the next servers
Broad-snouted CaimanOP
I am talking about development in my machine, not hosted Ubuntu server…So you are saying to use pm2 for development
@Rose-breasted Grosbeak Did you use pm2?
Broad-snouted CaimanOP
No