Cannot login after PHP upgrade to 7.2

Nextcloud version: 16.0.3
Operating system and version: CentOS 7
Apache or nginx version: nginx 1.14.2 with php-fpm
PHP version: 7.2

The issue you are facing:
After upgrading PHP to 7.2, I cannot login anymore using the browser.
The desktop app is still working fine and able to sync files
CalDav on my Android phone is not complaining either
When I try to login I just get redirected to the login page again.
This originally happened with Nextcloud 15.0.10, but I’ve since upgraded to 16.0.3 without any effect.
One other thing I did earlier was enabling 4-byte support in MySQL, not sure if that could have anything to do with it.
I’ve tried

  • disabling the cache (I was using the APCu module before)
  • resetting the password

When I log in using a wrong password, I get exactly the same result, the page reloads and there are no error messages. I did not find anything useful in either of the

  • Nginx logs
  • php logs
  • Nextcloud logs

The output of your Nextcloud log in Admin > Logging:
I cannot access Admin > Logging, but here is the log file
Note that I’ve set the logging level to 0, before there was not any output. The following segment has two login attempts on the webpage

{"reqId":"fCLaHdg55YQArDrXzb79","level":0,"time":"2019-07-20T15:22:44+00:00","remoteAddr":"213.47.83.233","user":"--","app":"core","method":"GET","url":"\/apps\/files\/","message":{"Exception":"OC\\AppFramework\\Middleware\\Security\\Exceptions\\NotLoggedInException","Message":"Current user is not logged in","Code":401,"Trace":[{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Middleware\/MiddlewareDispatcher.php","line":95,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\Security\\SecurityMiddleware","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\ViewController"},"index"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":98,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\ViewController"},"index"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\ViewController"},"index"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["ViewController","index",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"files.view.index"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"files.view.index"}]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"files.view.index"}]},{"file":"\/var\/www\/nextcloud\/lib\/base.php","line":975,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/files\/"]},{"file":"\/var\/www\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Middleware\/Security\/SecurityMiddleware.php","Line":143,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"m35p3UR7UYMiUz23x5zd","level":0,"time":"2019-07-20T15:22:46+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Run OC\\Authentication\\Token\\DefaultTokenCleanupJob job with ID 80","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"m35p3UR7UYMiUz23x5zd","level":0,"time":"2019-07-20T15:22:46+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Invalidating session tokens older than 2019-07-19T15:22:46+00:00","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"m35p3UR7UYMiUz23x5zd","level":0,"time":"2019-07-20T15:22:46+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Invalidating remembered session tokens older than 2019-07-05T15:22:46+00:00","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"m35p3UR7UYMiUz23x5zd","level":0,"time":"2019-07-20T15:22:46+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Invalidating session tokens older than 2019-07-19T15:22:46+00:00","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"m35p3UR7UYMiUz23x5zd","level":0,"time":"2019-07-20T15:22:46+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Invalidating remembered session tokens older than 2019-07-05T15:22:46+00:00","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"m35p3UR7UYMiUz23x5zd","level":0,"time":"2019-07-20T15:22:46+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Finished OC\\Authentication\\Token\\DefaultTokenCleanupJob job with ID 80 in 0 seconds","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"sYhqwOSqwvoQakA1Rb7K","level":0,"time":"2019-07-20T15:23:15+00:00","remoteAddr":"213.47.83.233","user":"--","app":"core","method":"GET","url":"\/apps\/files\/","message":{"Exception":"OC\\AppFramework\\Middleware\\Security\\Exceptions\\NotLoggedInException","Message":"Current user is not logged in","Code":401,"Trace":[{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Middleware\/MiddlewareDispatcher.php","line":95,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\Security\\SecurityMiddleware","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\ViewController"},"index"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":98,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\ViewController"},"index"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/App.php","line":126,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Files\\Controller\\ViewController"},"index"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["ViewController","index",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"files.view.index"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"files.view.index"}]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"files.view.index"}]},{"file":"\/var\/www\/nextcloud\/lib\/base.php","line":975,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/apps\/files\/"]},{"file":"\/var\/www\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Middleware\/Security\/SecurityMiddleware.php","Line":143,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"BipE2QYHG9faSeFUcU0T","level":0,"time":"2019-07-20T15:23:16+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Run OC\\Log\\Rotate job with ID 81","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}
{"reqId":"BipE2QYHG9faSeFUcU0T","level":0,"time":"2019-07-20T15:23:16+00:00","remoteAddr":"213.47.83.233","user":"--","app":"cron","method":"GET","url":"\/cron.php","message":"Finished OC\\Log\\Rotate job with ID 81 in 0 seconds","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko\/20100101 Firefox\/68.0","version":"16.0.3.0"}

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 => 'localhost',
    1 => '...',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => 'http://localhost',
  'dbtype' => 'mysql',
  'version' => '16.0.3.0',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => '...',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.secret' => '...',
  'mysql.utf8mb4' => true,
  'instanceid' => '...',
);

The output of your Apache/nginx/system log in /var/log/____:
access.log (there is no output to error.log during the login attempt)

213.47.83.233 - - [20/Jul/2019:11:19:50 -0400] "POST /login?redirect_url=/apps/files/ HTTP/2.0" 303 0 "https://cloud.simonparzer.com/login?redirect_url=/apps/files/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:50 -0400] "GET /apps/files/ HTTP/2.0" 303 0 "https://cloud.simonparzer.com/login?redirect_url=/apps/files/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:51 -0400] "GET /login?redirect_url=/apps/files/ HTTP/2.0" 200 3863 "https://cloud.simonparzer.com/login?redirect_url=/apps/files/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:51 -0400] "GET /core/fonts/Nunito-Bold.woff2 HTTP/2.0" 302 0 "https://cloud.simonparzer.com/core/css/guest.css?v=6a237ba9-0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:51 -0400] "GET /core/fonts/Nunito-Regular.woff2 HTTP/2.0" 302 0 "https://cloud.simonparzer.com/core/css/guest.css?v=6a237ba9-0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:52 -0400] "GET /cron.php HTTP/2.0" 200 40 "https://cloud.simonparzer.com/login?redirect_url=/apps/files/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:52 -0400] "GET /login HTTP/2.0" 200 3850 "https://cloud.simonparzer.com/core/css/guest.css?v=6a237ba9-0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"
213.47.83.233 - - [20/Jul/2019:11:19:52 -0400] "GET /login HTTP/2.0" 200 3842 "https://cloud.simonparzer.com/core/css/guest.css?v=6a237ba9-0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" "-"

Looks like this is the same issue: Nextcloud 16.0.1 Login Loop on Install
The PHP upgrade changed the owner of /var/lib/php/session/ to root:apache, I changed it back to nginx by sudo chgrp -R nginx /var/lib/php/session, then restarted through sudo systemctl restart php-fpm, now login works again!

1 Like

Thanks for self-replying, i’m probably gonna face this issue in a few days :smile:

Thanks for posting this solution! Using Nextcloud 19.0.3 Centos 8.2.200X, PHP 7.3.22, nginx/1.14.1 :smiley:

@Simon_Parzer Thank you! I’ve been using CentOS 8 for quite some time. At one point I migrated to PHP 7.2. Since NC21 requires 7.3 or better I just upgraded to PHP 7.4 and was getting frustrated because everything looked fine in NC as my desktop/android clients logged in but I couldn’t log in via the webpage! I host a lot of sites and it was only NC having issues which further confused me.

sudo chgrp -R nginx /var/lib/php/session
sudo systemctl restart php-fpm nginx

Did the trick!
:bowing_man: