Next.js Discord

Discord Forum

Next Deployment With NGINX gets 'killed' out of nowhere without any logs on a VPS

Unanswered
Pip gall wasp posted this in #help-forum
Open in Discord
Avatar
Pip gall waspOP
My nextjs deployment is done on a a very decent server with the stats in the screenshot attached.
I have used nginx to deploy and am starting npm run start as a pm2 service, and when this crash was happening in pm2 then in screens. Its a debian 11 deployment.

The problem is that it randomly gets killed out of nowhere. it just says 'Killed'. The htop logs is also shared. I'm confused as to what is killing it. It works fine for 30 mins or so then crashes itself. This is so confusing.

It works fine on a server without crashing or being killed in a VPS with 8 vcpus and 30 gigs, but i see no way that it uses 4 vcpus and take up so much memory. Any clues?
Image
Image

23 Replies

Avatar
Pm2 Will kill / restart your server your processes if they take up too much memory. Maybe you need to change the settings for how much memory they may use individually
Avatar
Pip gall waspOP
Screens is also killing it. I don't understand though if there is so much free storage and memory, how does pm2 decide too much memory is being taken??
Where you might think i can change this memory
cause its certianly not just pm2, screens kills it too
Just this
Image
in screens logs
Avatar
Its the “max_memory_restart” setting in the ecosystem config file
Avatar
Pip gall waspOP
@MikeTheTechLead max_memory_restart is only for pm2 tho right
screens is killing it as wel
Avatar
Im not sure what screens is and how youve implemented it. PM2 is a process manager for node. So it spins up next etc processes
Avatar
Pip gall waspOP
@MikeTheTechLead screens basically keeps the session going even if u close the ssh session
multiple terminal isntances basically u can do that run even if ssh session is broken
let me see if it works with pm2
with increased max_memory_restart
Avatar
Why would you need to keep the session running like that
Avatar
Pip gall waspOP
npm run start
either needs to be running on pm2, or screen
pm2 crashed
so i tested it on screen
to see if it was a pm2 related issue, screen crashes too
Avatar
Ah
Avatar
Pip gall waspOP
Does not work
It says 504 gateway timeout always