how to diagnose web server crashing

stackers

New Member
My server has been having issues lately. It will be fine for a few days, but then randomly start giving 502s. Sometimes I can't even SSH into the server when this happens, or it will be extremely slow. Like I have to wait a few minutes before the command line will let me enter anything.
A reboot always solves it, but if I'm not at my computer, it seems my server will be offline until I do.

If I can get in and run PM2 logs, I will see the following error over and over again:

MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]

It's a pretty typical web server: digital ocean/ ubuntu 16 / nginx / mongodb / pm2.

Here is what my digital ocean stats look like:
I see there is a huge spike in memory to 100%, as well as some big spikes in other things. But I'm not sure how to go about figuring out what's causing it.

There also seems to be disk usage spike, according to the mongodb monitoring:
 



Members online


Top