Nextcloud stuck in maintenance mode after update

Nextcloud version: 28.0.3
Operating system and version: Ubuntu 22.04.4 LTS
Apache or nginx version: Apache 2.4.52-1ubuntu4.7
PHP version: 8.1

The issue you are facing:

I have Nextcloud installed on a Raspberry Pi with the data stored on a mounted share. I haven’t been able to use the Nextcloud web updater since v28.0.0. I commented about it in this thread. However, since I was able to manually update following these instructions, I wasn’t too concerned about it. I got a notification that v28.0.3 was available. I tried the web updater again this evening and when that failed, I reverted to a manual upgrade. However, now my Nextcloud is stuck in maintenance mode. The web site just says “This Nextcloud instance is currently in maintenance mode, which may take a while. This page will refresh itself when the instance is available again.”

I’ve tried turning maintenance mode off with sudo -u www-data php occ maintenance:mode --on as well as making sure 'maintenance' was set to false in config.php (it was). I’ve restarted apache, rebooted the server, and even downgrading to v28.0.2 or 28.0.1.

Any help would be appreciated.

The output of your Nextcloud log in Admin > Logging:
Is that the same as the /var/log/nextcloud/nextcloud.log file? If so, that’s a rather large json file. But I’ll post it if necessary.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/nextcloud/apps',
      'url' => '/apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'oclw3oddunm8',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' =>
  array (
    0 => 'REDACTED',
  ),
  'datadirectory' => '/mnt/cloud',
  'dbtype' => 'mysql',
  'version' => '28.0.2.5',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud_admin',
  'dbpassword' => 'REDACTED',
  'logtimezone' => 'UTC',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 2,
  'installed' => true,
  'maintenance' => false,
  'trusted_proxies' =>
  array (
    0 => 'REDACTED',
  ),
  'theme' => '',
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => 'REDACTED',
  'mail_smtphost' => 'REDACTED',
  'mail_smtpport' => '25',
  'mysql.utf8mb4' => true,
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' =>
  array (
    0 => 'Family',
    1 => 'admin',
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
  ),
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'app_install_overwrite' =>
  array (
    0 => 'files_texteditor',
    1 => 'bruteforcesettings',
  ),
  'default_phone_region' => 'US',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0.0,
    'password' => 'REDACTED',
  ),
  'updater.secret' => 'REDACTED',
);
1 Like

Test the update with

sudo -u www-data php /path/to/nextcloud/updater/updater.phar

Post errors and logs. Do not use the web updater if you can use the command line.

So the last time I used the command line updater, it failed at the same point where the web updater failed, at the “Move new files in place” step. I just tried it again and it seems to have gotten past that step. However, I get PHP errors saying that rename() failed due to permissions issues. I’ve seen this before and I think it has to do with the data directory being on a shared drive. It wasn’t an issue last time, but it could be now. I can’t scroll back to the top when the update process started as there are too many lines, but here’s the last bit from the logs:

...
PHP Warning:  rename(/mnt/cloud/updater-oclw3oddunm8/downloads/nextcloud/index.php,/var/www/nextcloud/updater/../index.php): Operation not permitted in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 960
PHP Warning:  rename(/mnt/cloud/updater-oclw3oddunm8/downloads/nextcloud/public.php,/var/www/nextcloud/updater/../public.php): Operation not permitted in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 960
PHP Warning:  rename(/mnt/cloud/updater-oclw3oddunm8/downloads/nextcloud/remote.php,/var/www/nextcloud/updater/../remote.php): Operation not permitted in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 960
PHP Warning:  rename(/mnt/cloud/updater-oclw3oddunm8/downloads/nextcloud/status.php,/var/www/nextcloud/updater/../status.php): Operation not permitted in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 960
[✔] Move new files in place
[ ] Done ...
PHP Warning:  rename(/mnt/cloud/updater-oclw3oddunm8/downloads/nextcloud/updater/index.php,/var/www/nextcloud/updater/../updater/index.php): Operation not permitted in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 960
PHP Warning:  rename(/mnt/cloud/updater-oclw3oddunm8/downloads/nextcloud/updater/updater.phar,/var/www/nextcloud/updater/../updater/updater.phar): Operation not permitted in phar:///var/www/nextcloud/updater/updater.phar/lib/Updater.php on line 960
[✔] Done

Update of code successful.

Should the "occ upgrade" command be executed? [Y/n] y
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Repair step: Repair MySQL collation
Repair info: All tables already have the correct collation -> nothing to do
Repair step: Copy data from accounts table when migrating from ownCloud
Repair step: Drop account terms table when migrating from ownCloud
Updating database schema
Updated database
Repair step: Repair MySQL collation
...
Starting code integrity check...
Finished code integrity check
Update successful
Maintenance mode is kept active
Resetting log level

Keep maintenance mode active? [y/N] y
Maintenance mode disabled

Maintenance mode is disabled

I checked the web page and it’s still in maintenance mode:

The version.php file says I’m on 28.0.3 and config.php says 'maintenance' => false,.

The files and directories are all owned by www-data and the date/time stamps are all accurate to when the update was run this morning.

This is exactly where I would have expected the error to occur, or at a non-writable mountpoint. Maybe you can recursively set everything again for user www-data and group www-data.

Ok, I ran the 3 commands from the “Upgrade manually” page:

chown -R www-data:www-data nextcloud
find nextcloud/ -type d -exec chmod 750 {} \;
find nextcloud/ -type f -exec chmod 640 {} \;

Same results. Even after restarting the web server. I also tried a different browser (one I never use) just in case it was some strange caching thing.

Test
sudo -u www-data php occ maintenance:mode --off
Maybe some other commands e.g.
sudo -u www-data php occ maintenance:repair
occ maintenance

Running the command to turn off maintenance mode just gives the output Maintenance mode already disabled. And the repair runs through, everything seems Ok.

Same results on the web page. Still in maintenance mode.

For me, it can take a bit of time between disabling it and until the webinterface does not show the maintenance message any more (30s - 60s).

This may be the reason:
One or more apps are not compatible. So Nextcloud remains in maintenance mode.

Well, I first encountered this last night. It was in “maintenance mode” for several hours over night. And most recently, for over 30 minutes.

I’m pretty sure I had previously disabled all 3rd party apps. Even so, I know I didn’t bring any over when I did a manual upgrade. Is there a way to tell which apps are not compatible?

Post a list of all apps.

Is a listing of the apps directory good enough?

root /var/www/nextcloud # ls apps/
activity              files_sharing            settings
admin_audit           files_trashbin           sharebymail
bruteforcesettings    files_versions           support
circles               firstrunwizard           survey_client
cloud_federation_api  logreader                suspicious_login
comments              lookup_server_connector  systemtags
contactsinteraction   nextcloud_announcements  text
dashboard             notifications            theming
dav                   oauth2                   twofactor_backupcodes
encryption            password_policy          twofactor_totp
federatedfilesharing  photos                   updatenotification
federation            privacy                  user_ldap
files                 provisioning_api         user_status
files_external        recommendations          viewer
files_pdfviewer       related_resources        weather_status
files_reminders       serverinfo               workflowengine

In case it’s useful, this was the output from the maintenance:repair command:

root /var/www/nextcloud # sudo -u www-data php occ maintenance:repair
 - Repair MySQL collation
     - All tables already have the correct collation -> nothing to do
 - Repair mime types
 - Clean tags and favorites
     - 0 tags of deleted users have been removed.
     - 0 tags for delete files have been removed.
     - 0 tag entries for deleted tags have been removed.
     - 0 tags with no entries have been removed.
 - Repair invalid shares
 - Move .step file of updater to backup location
 - Add move avatar background job
     - Repair step already executed
 - Add preview cleanup background jobs
 - Migrate oauth2_clients table to nextcloud schema
     - Update the oauth2_access_tokens table schema.
     - Update the oauth2_clients table schema.
     - Delete clients (and their related access tokens) with the redirect_uri starting with oc:// or ending with *
 - Fix potential broken mount points
     - No mounts updated
 - Repair language codes
 - Add log rotate job
 - Clear frontend caches
     - Image cache cleared
     - JS cache cleared
 - Clear every generated avatar
 - Add preview background cleanup job
 - Queue a one-time job to cleanup old backups of the updater
 - Cleanup invalid photocache files for carddav
 - Add background job to cleanup login flow v2 tokens
 - Remove potentially over exposing share links
     - No need to remove link shares.
 - Clear access cache of projects
 - Reset generated avatar flag
 - Keep legacy encryption enabled
 - Check encryption key format
 - Remove old dashboard app config data
 - Add job to cleanup the bruteforce entries
 - Queue a one-time job to check for user uploaded certificates
 - Repair DAV shares
 - Add background job to set the lookup server share state for users
 - Add token cleanup job
 - Clean up abandoned apps
 - Add possibly missing system config
 - Add AI tasks cleanup job
 - Queue a job to generate metadata
 - Upgrading Circles App
 - Fix component of birthday calendars
     - 3 birthday calendars updated.
 - Regenerating birthday calendars to use new icons and fix old birthday events without year
     - Repair step already executed
 - Fix broken values of calendar objects
    0 [->--------------------------]
 - Registering building of calendar search index as background job
     - Repair step already executed
 - Register building of social profile search index as background job
     - Repair step already executed
 - Registering background jobs to update cache for webcal calendars
     - Added 0 background jobs to update webcal calendars
 - Registering building of calendar reminder index as background job
     - Repair step already executed
 - Clean up orphan event and contact data
     - 0 events without a calendar have been cleaned up
     - 0 properties without an events have been cleaned up
     - 0 changes without a calendar have been cleaned up
     - 0 cached events without a calendar subscription have been cleaned up
     - 0 changes without a calendar subscription have been cleaned up
     - 0 contacts without an addressbook have been cleaned up
     - 0 properties without a contact have been cleaned up
     - 0 changes without an addressbook have been cleaned up
 - Remove activity entries of private events
     - Removed 0 activity entries
 - Clean up old calendar subscriptions from deleted users that were not cleaned-up
    0 [----->----------------------]
     - 0 calendar subscriptions without an user have been cleaned up
 - Remove invalid object properties
     - 0 invalid object properties removed.
 - Fix the share type of guest shares when migrating from ownCloud
 - Copy the share password into the dedicated column
 - Set existing shares as accepted
 - Update OAuth token expiration times
 - Initialize migration of background images from dashboard to theming app
 - Add background job to check for backup codes
 - Populating added database structures for workflows

It might be better do execute

occ app:list

You will get the version numbers as well as an overview, which apps are disabled.

root /var/www/nextcloud # sudo -u www-data php occ app:list
Enabled:
  - activity: 2.20.0
  - bruteforcesettings: 2.8.0
  - circles: 28.0.0-dev
  - cloud_federation_api: 1.11.0
  - comments: 1.18.0
  - dav: 1.29.1
  - federatedfilesharing: 1.18.0
  - files: 2.0.0
  - files_pdfviewer: 2.9.0
  - files_reminders: 1.1.0
  - files_sharing: 1.20.0
  - files_trashbin: 1.18.0
  - files_versions: 1.21.0
  - logreader: 2.13.0
  - lookup_server_connector: 1.16.0
  - nextcloud_announcements: 1.17.0
  - notifications: 2.16.0
  - oauth2: 1.16.3
  - password_policy: 1.18.0
  - photos: 2.4.0
  - privacy: 1.12.0
  - provisioning_api: 1.18.0
  - recommendations: 2.0.0
  - related_resources: 1.3.0
  - serverinfo: 1.18.0
  - settings: 1.10.1
  - sharebymail: 1.18.0
  - theming: 2.3.0
  - twofactor_backupcodes: 1.17.0
  - twofactor_totp: 10.0.0-beta.2
  - updatenotification: 1.18.0
  - viewer: 2.2.0
  - workflowengine: 2.10.0
Disabled:
  - admin_audit: 1.18.0
  - contactsinteraction: 1.9.0 (installed 1.1.0)
  - dashboard: 7.8.0 (installed 7.0.0)
  - encryption: 2.16.0
  - federation: 1.18.0 (installed 1.4.0)
  - files_external: 1.20.0
  - firstrunwizard: 2.17.0 (installed 2.9.0)
  - support: 1.11.0 (installed 1.0.0)
  - survey_client: 1.16.0 (installed 1.2.0)
  - suspicious_login: 6.0.0
  - systemtags: 1.18.0 (installed 1.4.0)
  - text: 3.9.1 (installed 1.1.1)
  - user_ldap: 1.19.0
  - user_status: 1.8.1 (installed 1.0.1)
  - weather_status: 1.8.0 (installed 1.0.0)

FWIW, the sudo -u www-data php occ app:update --all command shows no output. I’m guessing there are no updates available for any of my apps.

Well, I got it fixed. It seems to have been a permissions issue on the mounted share, which I don’t understand since I haven’t changed anything on that in years. I noticed that all the files in the share had root:www-data ownership permissions. Must have something to do with all the manual updates I’ve been having to do.

Anyway, I just had to do:

sudo chown -R www-data: /mnt/cloud/

Reboot and all is well!

A lot of apps are not up to date. You should urgently solve the problem. If necessary, uninstall all manually installed apps first. You should find it in the GUI at https://cloud.server.tld/settings/apps.

I got my instance working yesterday. But there seems to be a bit of a version mismatch with these apps. I went to the list of apps this morning and all the versions (even the disabled ones) match the latest versions listed in my output previously.

I just ran the app:list command again:

# sudo -u www-data php occ app:list
...
Disabled:
  - admin_audit: 1.18.0
  - contactsinteraction: 1.9.0 (installed 1.1.0)
  - dashboard: 7.8.0 (installed 7.0.0)
  - encryption: 2.16.0
  - federation: 1.18.0 (installed 1.4.0)
  - files_external: 1.20.0
  - firstrunwizard: 2.17.0 (installed 2.9.0)
  - support: 1.11.0 (installed 1.0.0)
  - survey_client: 1.16.0 (installed 1.2.0)
  - suspicious_login: 6.0.0
  - systemtags: 1.18.0 (installed 1.4.0)
  - text: 3.9.1 (installed 3.9.1)
  - user_ldap: 1.19.0
  - user_status: 1.8.1 (installed 1.0.1)
  - weather_status: 1.8.0 (installed 1.0.0)

So I’m not sure what’s going on or which version to believe, but these are disabled apps so I’m not too concerned about it.