Nextcloud keeps crashing (Solution)

Nextcloud crashing all the time

Recently I have set up NextCloud running on an AWS instance in our private VPC.

The predominant reasoning behind this was to provide a frontend to our S3 storage which we were using to replace our internal FreeNAS storage.

(We were initially using AWS S3 for the backend but data access costs proved prohibitive and we soon moved on to Wasabi bu this is a story for another time / another post)

NextCloud is a great solution and provides a plethora of functions which we are yet to fully explore, the only problem was when I rolled it out company wide it kept crashing!

At first I thought the problem was storage: I had deliberately chosen a small volume on the instance as all data was meant to be stored in the cloud. However individuals kept uploading their files into the wrong directory which did indeed crash the server. I solved this issue by limiting the local storage space allocated to each user, meaning if they did upload to the wrong directory they would get an error message.

However NextCloud kept crashing.

I then thought it may be a memory issue so I increased this along with swap space but still NextCloud crashed.

The Solution

After averaging one crash every week for 3 weeks on the trot I got used to having to reboot the NextCloud server, I stumbled across a problem with php7.2-fpm.service.

Every time I was getting an Internal Server Error it was the php7.2-fpm.service that was failing, by me rebooting the server it was just restarting the service and allowing NextCloud to work again.

So after weeks of pulling my hair out the simple solution was to write a small script to check on the status of php7.2-fpm.service and if it was down to restart it, I then added a cronjob to run this every 5 minutes and job done. No more crashes.

My crontab entry looks like this:

5 * * * * root restartphp

And you can find myscript which I put in /usr/bin and made executable can be found here:

https://github.com/donbale/systemd_restart

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.