Permanent maintenance mode because eror 503 for all

Nextcloud version (eg, 20.0.5): 24.0.7.1
Operating system and version (eg, Ubuntu 20.04): CentOS Linux release 7.9.2009
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.6
PHP version (eg, 7.4): 7.4.33

The issue you are facing:

I’m not sure, probably after/during upgrade some application in NC someting gone wrong.
After that I run occ upgrade with success, but nothing changed.

occ maintenance:repair - noting found, not help

occ files:repair-tree 
Found 0 file entries with an invalid path
occ files:cleanup -v
0 orphaned file cache entries deleted
3 orphaned mount entries deleted

occ app:update --all - made some updates
occ maintenance:mode --off - nothing happen

I disabled some apps, until:

"app":"no app in context","method":"GET","url":"/index.php/csrftoken","message":"Unable to generate a URL for the named route \"files.view.index\" as such route does not exist.

then I don’t known what app I can disable, because

occ app:disable files
files can't be disabled.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. I don’t know

The output of your Nextcloud log in Admin > Logging:

no access

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

$CONFIG = array (
  'passwordsalt' => '....,
  'secret' => '....',
  'trusted_domains' => 
  array (
    0 => 'my.fqdn.zzz',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.7.1',
  'overwrite.cli.url' => 'https://my.fqdn.zzz',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '...',
  'dbpassword' => '....',
  'installed' => true,
  'mysql.utf8mb4' => true,
  'maintenance' => false,
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'nc',
  'mail_domain' => 'fqdn.zzz',
  'has_rebuilt_cache' => true,
  'app.mail.verify-tls-peer' => false,
  'theme' => '',
  'app_install_overwrite' => 
  array (
    0 => 'calendar',
    1 => 'tasks',
    2 => 'ocsms',
    3 => 'files_external_gdrive',
    4 => 'dashboard',
    5 => 'orcid',
    6 => 'zenodo',
    7 => 'spreed',
    8 => 'cookbook',
    9 => 'githubmergetracker',
    10 => 'files_frommail',
    11 => 'telephoneprovider',
  ),
  'instanceid' => 'ocboo1mcujao',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'default_language' => 'pl',
  'default_locale' => 'pl_PL',
  'loglevel' => 1,
  'default_phone_region' => 'PL',
);

The output of your Apache/nginx/system log in /var/log/____:

xx.xx.xx.xx - - [22/Nov/2022:21:25:33 +0100] "GET / HTTP/1.1" 503 12888
xx.xx.xx.xx - - [22/Nov/2022:21:25:34 +0100] "GET /core/css/guest.css?v=64701105-13 HTTP/1.1" 200 21612
xx.xx.xx.xx - - [22/Nov/2022:21:25:34 +0100] "GET /core/l10n/pl.js?v=64701105-13 HTTP/1.1" 200 62882
xx.xx.xx.xx - - [22/Nov/2022:21:25:34 +0100] "GET /dist/core-maintenance.js?v=64701105-13 HTTP/1.1" 200 2423
xx.xx.xx.xx - - [22/Nov/2022:21:25:34 +0100] "GET /dist/core-main.js?v=64701105-13 HTTP/1.1" 200 137689
xx.xx.xx.xx - - [22/Nov/2022:21:25:35 +0100] "GET /core/img/background.png?v=2 HTTP/1.1" 200 9621
xx.xx.xx.xx - - [22/Nov/2022:21:25:35 +0100] "GET /core/img/logo/logo.svg?v=1 HTTP/1.1" 200 815
xx.xx.xx.xx - - [22/Nov/2022:21:25:35 +0100] "GET /core/img/actions/error-white.svg?v=1 HTTP/1.1" 200 224
xx.xx.xx.xx - - [22/Nov/2022:21:25:37 +0100] "GET /core/img/favicon-touch.png HTTP/1.1" 200 4196
xx.xx.xx.xx - - [22/Nov/2022:21:25:37 +0100] "GET /core/img/favicon.ico HTTP/1.1" 200 3262
xx.xx.xx.xx - - [22/Nov/2022:21:25:34 +0100] "GET /dist/core-common.js?v=64701105-13 HTTP/1.1" 200 9474112
xx.xx.xx.xx - - [22/Nov/2022:21:25:44 +0100] "GET /status.php HTTP/1.1" 200 168

When try open dashboard:

xx.xx.xx.xx - - [22/Nov/2022:21:27:39 +0100] "GET /index.php/apps/dashboard/ HTTP/1.1" 503 12888
xx.xx.xx.xx - - [22/Nov/2022:21:27:40 +0100] "GET /core/css/guest.css?v=64701105-13 HTTP/1.1" 200 21612
xx.xx.xx.xx - - [22/Nov/2022:21:27:40 +0100] "GET /dist/core-maintenance.js?v=64701105-13 HTTP/1.1" 200 2423
xx.xx.xx.xx - - [22/Nov/2022:21:27:40 +0100] "GET /core/l10n/pl.js?v=64701105-13 HTTP/1.1" 200 62882
xx.xx.xx.xx - - [22/Nov/2022:21:27:40 +0100] "GET /dist/core-main.js?v=64701105-13 HTTP/1.1" 200 137689
xx.xx.xx.xx - - [22/Nov/2022:21:27:41 +0100] "GET /core/img/background.png?v=2 HTTP/1.1" 200 9621
xx.xx.xx.xx - - [22/Nov/2022:21:27:41 +0100] "GET /core/img/logo/logo.svg?v=1 HTTP/1.1" 200 815
xx.xx.xx.xx - - [22/Nov/2022:21:27:41 +0100] "GET /core/img/actions/error-white.svg?v=1 HTTP/1.1" 200 224
xx.xx.xx.xx - - [22/Nov/2022:21:27:43 +0100] "GET /core/img/favicon.ico HTTP/1.1" 200 3262
xx.xx.xx.xx - - [22/Nov/2022:21:27:43 +0100] "GET /core/img/favicon-touch.png HTTP/1.1" 200 4196

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"Y30x9YL@t-KPufeeCoVJKgAAAAk","level":1,"time":"2022-11-22T20:32:53+00:00","remoteAddr":"xx.xx.xx.xx",
"user":"--",
"app":"no app in context","method":"GET","url":"/index.php/apps/passwords/api/1.0/session/keepalive",
"message":"Unable to generate a URL for the named route \"appointments.page.index\" as such route does not exist.",
"userAgent":"Oficialny Klient Hasla (Passwords) dla Firefox na Linux",
"version":"23.0.11.1",
"exception":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException",
"Message":"Unable to generate a URL for the named route \"appointments.page.index\" as such route does not xist.",
"Code":0,
"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Route/Router.php","line":361,
"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Route/CachingRouter.php",
"line":58,
"function":"generate","class":"OC\\Route\\Router","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/URLGenerator.php",
"line":91,
"function":"generate","class":"OC\\Route\\CachingRouter","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/NavigationManager.php",
"line":287,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/NavigationManager.php",
"line":113,"function":"init","class":"OC\\NavigationManager","type":"->"},
{"file":"/var/www/html/nextcloud/apps/theming/lib/ThemingDefaults.php",
"line":199,"function":"getAll","class":"OC\\NavigationManager","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Defaults.php",
"line":280,"function":"getShortFooter","class":"OCA\\Theming\\ThemingDefaults","type":"->"},
{"file":"/var/www/html/nextcloud/lib/public/Defaults.php",
"line":177,"function":"getLongFooter","class":"OC_Defaults","type":"->"},
{"file":"/var/www/html/nextcloud/core/templates/layout.guest.php",
"line":54,"function":"getLongFooter","class":"OCP\\Defaults","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":180,"args":["/var/www/html/nextcloud/co
re/templates/layout.guest.php"],"function":"include"},
{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":150,"function":"load","class":"OC\\Template\\Base","type":"->"},{
"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Template.php","line":182,"function":"fetchPage","class":"OC\\Template\\Base","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/l
egacy/OC_Template.php",
"line":213,"function":"fetchPage","class":"OC_Template","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage",
"class":"OC_Template","type":"->"},
{"file":"/var/www/html/nextcloud/lib/base.php","line":302,"function":"printPage","class":"OC\\Template\\Base","type":"->"},
{"file":"/var/www/html/nextcloud/lib/base.php",
"line":973,"function":"checkMaintenanceMode","class":"OC","type":"::"},
{"file":"/var/www/html/nextcloud/index.php",
"line":36,"function":"handleRequest","class":"OC","type":"::"}],
"File":"/var/www/html/nextcloud/3rdparty/symfony/routing/Generator/UrlGenerator.php",
"Line":143,"message":"Unable to generate a URL for the named route \"appointments.page.index\" as such route does not exist.",
"exception":{},"CustomMessage":"Unable to generate a URL for the named route \"appointments.page.index\" as such route does not exist."}}

{"reqId":"Y30x9YL@t-KPufeeCoVJKgAAAAk","level":1,"time":"2022-11-22T20:32:53+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"no app in context","method":"GET","url":"/index.php/apps/passwords/api/1.0/session/keepalive",
"message":"Unable to generate a URL for the named route \"calendar.view.index\" as such route does not exist.",
"userAgent":"Oficialny Klient Hasla (Passwords) dla Firefox na Linux","version":"23.0.11.1",
"exception":{"Exception":"Symfony\\Component\\Routing\\Exception\\RouteNotFoundException",
"Message":"Unable to generate a URL for the named
route \"calendar.view.index\" as such route does not exist.",
"Code":0,
"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Route/Router.php",
"line":361,"function":"generate","class":"Symfony\\Component\\Routing\\Generator\\UrlGenerator","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/Route/CachingRouter.php","line":58,"function":"generate","class":"OC\\Route\\Router"
,"type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/URLGenerator.php","line":91,"function":"generate","class":"OC\\Route\\CachingRouter","type":"->"},
{"file":"/var/www/html/nextcloud/
lib/private/NavigationManager.php","line":287,"function":"linkToRoute","class":"OC\\URLGenerator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/NavigationManager.php","line":113,
"function":"init","class":"OC\\NavigationManager","type":"->"},{"file":"/var/www/html/nextcloud/apps/theming/lib/ThemingDefaults.php","line":199,"function":"getAll","class":"OC\\NavigationMa
nager","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Defaults.php","line":280,"function":"getShortFooter","class":"OCA\\Theming\\ThemingDefaults","type":"->"},
{"file":"/var/www/html/nextcloud/lib/public/Defaults.php","line":177,"function":"getLongFooter","class":"OC_Defaults","type":"->"},
{"file":"/var/www/html/nextcloud/core/templates/layout.guest.php","l
ine":54,"function":"getLongFooter","class":"OCP\\Defaults","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":180,"args":["/var/www/html/nextcloud/core/templ
ates/layout.guest.php"],"function":"include"},{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":150,"function":"load","class":"OC\\Template\\Base","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Template.php","line":182,"function":"fetchPage","class":"OC\\Template\\Base","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/legacy/OC
_Template.php","line":213,"function":"fetchPage","class":"OC_Template","type":"->"},
{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":
"OC_Template","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":302,"function":"printPage","class":"OC\\Template\\Base","type":"->"},
{"file":"/var/www/html/nextcloud/lib/bas
e.php","line":973,"function":"checkMaintenanceMode","class":"OC","type":"::"},
{"file":"/var/www/html/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"Fil
e":"/var/www/html/nextcloud/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":143,"message":"Unable to generate a URL for the named route \"calendar.view.index\" as such route does
 not exist.","exception":{},"CustomMessage":"Unable to generate a URL for the named route \"calendar.view.index\" as such route does not exist."}}

or better formated

{
  "reqId": "Y30OxwR3JQLGwTfYveLFSwAAAAo",
  "level": 1,
  "time": "2022-11-22T18:02:47+00:00",
  "remoteAddr": "185.180.143.79",
  "user": "--",
  "app": "no app in context",
  "method": "GET",
  "url": "/",
  "message": "Unable to generate a URL for the named route \"ocs.password_policy.API.validate\" as such route does not exist.",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
  "version": "23.0.11.1",
  "exception": {
    "Exception": "Symfony\\Component\\Routing\\Exception\\RouteNotFoundException",
    "Message": "Unable to generate a URL for the named route \"ocs.password_policy.API.validate\" as such route does not exist.",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/nextcloud/lib/private/Route/Router.php",
        "line": 361,
        "function": "generate",
        "class": "Symfony\\Component\\Routing\\Generator\\UrlGenerator",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Route/CachingRouter.php",
        "line": 58,
        "function": "generate",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/URLGenerator.php",
        "line": 107,
        "function": "generate",
        "class": "OC\\Route\\CachingRouter",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/apps/password_policy/lib/Capabilities.php",
        "line": 59,
        "function": "linkToOCSRouteAbsolute",
        "class": "OC\\URLGenerator",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/CapabilitiesManager.php",
        "line": 75,
        "function": "getCapabilities",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Template/JSConfigHelper.php",
        "line": 190,
        "function": "getCapabilities",
        "class": "OC\\CapabilitiesManager",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/TemplateLayout.php",
        "line": 223,
        "function": "getConfig",
        "class": "OC\\Template\\JSConfigHelper",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/legacy/OC_Template.php",
        "line": 185,
        "function": "__construct",
        "class": "OC\\TemplateLayout",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/private/Template/Base.php",
        "line": 132,
        "function": "fetchPage",
        "class": "OC_Template",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/base.php",
        "line": 809,
        "function": "printPage",
        "class": "OC\\Template\\Base",
        "type": "->"
      },
      {
        "file": "/var/www/html/nextcloud/lib/base.php",
        "line": 1111,
        "function": "init",
        "class": "OC",
        "type": "::"
      },
      {
        "file": "/var/www/html/nextcloud/index.php",
        "line": 34,
        "args": [
          "/var/www/html/nextcloud/lib/base.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/html/nextcloud/3rdparty/symfony/routing/Generator/UrlGenerator.php",
    "Line": 143,
    "message": "Unable to generate a URL for the named route \"ocs.password_policy.API.validate\" as such route does not exist.",
    "exception": {},
    "CustomMessage": "Unable to generate a URL for the named route \"ocs.password_policy.API.validate\" as such route does not exist."
  }
}

Hi,

did you try sudo -u www-data php occ maintenance:mode --off ?

Yes, I mentioned on top.
But, today I check NC and magically everything works fine - realy strange.

Probably, after this

Nov 23 09:05:01 xxx CROND[32521]: (apache) CMD (php --define apc.enable_cli=1 -f /var/www/html/nextcloud/cron.php)

Nextcloud start running fine.