Nextcloud stuck on maintenance mode

i managed to manually turned maintenance mode off however it keeps turning back to “on” and also the occ commands in terminal not working. how to update nextcloud. Any help will ne greatly appreciated.

Can you access the terminal on your server? If so, open the Nextcloud config file (/nextcloud/config/config.php) and change the following line:

‘maintenance’ => true,


‘maintenance’ => false,

Remember to restart Apache or NGINX and your Nextcloud instance should be accessible again.

i have tried that multiple times. when i turn it to false it gives me the access to update again and automatically turn maintenance mode back to on

You’re not stuck on maintenance mode, there is an error when updating – it looks like your database. I haven’t had a database error like this before, but you might want to update the indices and if all else fails, go for a manual update strategy as I’ve had to default to just this morning.

can you please help me on how to do such updates?

It’s in the nextcloud documentation – manual upgrade. I’d write out the steps here but it pretty much spells it out step for step in the documentation. I’ve unfortunately had to default to this method a lot recently when either the web updater (which is what you are using), or the phar updater just like freezes.

insect the HTTP network log in your browser and the nextcloud.log on your server. either of the two if not both might have more details on what went wrong specifically

i would like to do a manual upgrade unfortunately i do not know how to fix errors. i do not want to mess it up because im not really hands on to fixing errors. i have some important data that i dont want to lose. I learned how to create my nexcloud instance through a youtube video. everything was good until i tried to do an update which i thought would be automatic and now im stuck.

If you separated your data from the actual application you won’t lose data when upgrading nextcloud. The database and data storage should be separate from the application.

i am pretty sure I’ve done that when i set it up but how do i check for that? i downloaded the latest version of nextcloud but i dont know how to migrate all the data to the fresh install

Honestly I don’t know since it would depend on how you set up your nextcloud. Usually by default however the manual install process does not overwrite data directories – it unzips new directories on top of the old. You need however to back up your config.php file for sure since this will be overwritten. Kind of off topic however you should be backing up your data directory and database kind of regularly in case of catastrophic loss.

To find the location of your data directory, look in your config.php file for the following line:

'datadirectory' => '/var/www/XXXXXXXXXXXX',

That is the location of your data directory and ideally it should be outside of /nextcloud.

Is your data encrypted on the server? If not be sure to backup your data directory directly from the server so you have a copy in case something goes wrong. You should also backup the database and nextcloud folder so you can recover.

Assuming your nextcloud folder is located in /www and your server is running apache with www-data as the user, execute the following command to manually update:

sudo -u www-data php /var/www/nextcloud/updater/updater.phar

This is unlikely to solve your problem though because your issue seems to be caused by a database error. After you back everything up you can give the manual update a try manually because it won’t hurt anything.

More info here:

i will definitely try that command as soon as i get home. thanks for your help. yes my server is running apache with www-data as user. to make it easier for your help i had followed a video title nextcloud on linode by LearnlinuxTV .