After latest php8.2 updates for ubuntu server i.e. php-redis, php8.2-redis (login screen loops) no conn to redis.sock

I had problems to get login to my webui via browser and investigated that all occ commands leads into errors. Also redis was not reachable.

So i found this thread on github

and repaired my groupfoldes app and get back access via terminal to occ commands.
I tested redis (notify_push) that gave back the following

sudo -u www-data php /var/www/nextcloud/occ notify_push:self-test
✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
✓ push server is running the same version as the app

Rebooted the server and got back my login screen of NC

NC Version is 27.0.2, on ubuntu 22.04.3 with nginx and php8.2-fpm
Clients on Android and iOS are connected via App-Token because of installed and activated 2FA.

Try to login via Browser gives back a 502 Bad Gateway error after credentials ans login button.

In logfiles i see now

Sep 13 11:27:14 cloud notify_push[2205]: [2023-09-13 11:27:14.700898 +02:00] WARN [notify_push::connection] src/connection.rs:75: Error while sending authentication request to nextcloud

I tried to switch php session handler to “files” instead of redis but no effect.
I tried to disable the 2fa app but got the same 502 Bad Gateway error.

The 2FA and groupfolders app are reactivated for the moment, otherwise my android clients can’t access some folders…

cron jobs are running - seeing nextcloud.log (every 5 minutes)

alls webui clients get the 502 Bad Gatway login error (independent if 2FA enabled or not)

Thanks for any help…

It seems to be a php-redis / php8.2-redis related problem …

Preparing to unpack …/php8.2-redis_6.0.0-1+ubuntu22.04.1+deb.sury.org+1_amd64.deb …
Unpacking php8.2-redis (6.0.0-1+ubuntu22.04.1+deb.sury.org+1) over (6.0.0-1+ubuntu22.04.1+deb.sury.org+1) …
Setting up php8.2-redis (6.0.0-1+ubuntu22.04.1+deb.sury.org+1) …
Processing triggers for php8.2-phpdbg (8.2.10-1+ubuntu22.04.1+deb.sury.org+2) …
Processing triggers for php8.2-cgi (8.2.10-1+ubuntu22.04.1+deb.sury.org+2) …
Processing triggers for php8.2-cli (8.2.10-1+ubuntu22.04.1+deb.sury.org+2) …
Processing triggers for php8.2-fpm (8.2.10-1+ubuntu22.04.1+deb.sury.org+2) …

This is the version i get with the latest update several days before and since then the login no longer works!
I restored a backup NC 27.0.2 from 28.08.2023 and before i updated this Status i could login without problems. Are there any others outside using redis for php sessions and can’t login any longer?

see: Nextcloud Unix-Socket Kommunikation (Ubuntu 22.04/Debian12) - Carsten Rieger IT-Services

With my restored backup i got now a looping login screen instead of 502 Bad Gateway but can’t login to any browser anyway.

In NGinx error log i see

> #5 /var/www/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuild" while reading response header from upstream, client: 192.168.55.90, server:MY.DOMAIN, request: "GET /ocs/v2.php/apps/user_status/api/v1/user_status?format=json HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.2-fpm.sock:", host: "MY.DOMAIN"
> 2023/09/14 16:41:01 [error] 1530#1530: *562 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
> 	Is the server running locally and accepting connections on that socket? in /var/www/nextcloud/lib/private/DB/Connection.php:140

Can’ t understand the error message because /run/postgresql/… exist
see Screenshot

I can connect to NC via WebDav CalDav and CardDAV! but not via Browser

Logins via Browser are quittet by

{"reqId":"jCLw7KWNCRf4kaZa9WHN","level":3,"time":"2023-09-14T18:03:20+02:00","remoteAddr":"192.168.55.92","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/christian/","message":"session_start(): Redis connection not available at /var/www/nextcloud/lib/private/Session/Internal.php#222","userAgent":"Mozilla/5.0 (Windows) mirall/3.9.3stable-Win64 (build 20230818) (Nextcloud, windows-10.0.22621 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"27.0.2.1","data":{"app":"PHP"}}
{"reqId":"jCLw7KWNCRf4kaZa9WHN","level":3,"time":"2023-09-14T18:03:20+02:00","remoteAddr":"192.168.55.92","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/christian/","message":"session_start(): Failed to read session data: redis (path: /var/run/redis/redis.sock?persistent=1&weight=1&database=20) at /var/www/nextcloud/lib/private/Session/Internal.php#222","userAgent":"Mozilla/5.0 (Windows) mirall/3.9.3stable-Win64 (build 20230818) (Nextcloud, windows-10.0.22621 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"27.0.2.1","data":{"app":"PHP"}}

But redis.sock is there

another log entry says

2023/09/14 16:42:31 [crit] 1530#1530: *586 connect() to unix:/run/php/php8.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.55.90, server: MY.DOMAIN, request: "PROPFIND /remote.php/dav/files/USER-XY/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.2-fpm.sock:", host: "MY.DOMAIN"

here the same the sock exist

see

My NC config

{
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "192.168.55.16",
        "MY.DOMAIN"
    ],
    "activity_expire_days": 14,
    "auth.bruteforce.protection.enabled": true,
    "blacklisted_files": [
        ".htaccess",
        "Thumbs.db",
        "thumbs.db"
    ],
    "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
    "overwritehost": "MY.DOMAIN",
    "overwriteconaddr": "^192\\.168\\.55\\.90$",
    "overwriteprotocol": "https",
    "forward_for_headers": [
        "X_FORWARDED_FOR",
        "HTTP_X_FORWARDED_FOR"
    ],
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "overwrite.cli.url": "https:\/\/MY.DOMAIN",
    "dbtype": "pgsql",
    "version": "27.0.2.1",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "/run/postgresql",
    "dbport": "",
    "dbtableprefix": "oc_",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "htaccess.RewriteBase": "\/",
    "logtimezone": "Europe\/Berlin",
    "default_phone_region": "DE",
    "logfile": "\/media\/cloud\/data\/nextcloud.log",
    "log_rotate_size": 10485760,
    "cron_log": true,
    "installed": true,
    "filesystem_check_changes": 0,
    "quota_include_external_storage": false,
    "skeletondirectory": "",
    "share_folder": "\/Freigaben",
    "knowledgebaseenabled": false,
    "ldapIgnoreNamingRules": false,
    "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
    "ldapUserCleanupInterval": 20,
    "bulkupload.enabled": false,
    "memcache.local": "\\OC\\Memcache\\APCu",
    "memcache.distributed": "\\OC\\Memcache\\Redis",
    "filelocking.enabled": "true",
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "redis": {
        "host": "/var/run/redis/redis.sock",
        "port": 0,
        "dbindex": 0,
        "timeout": 1.5
    },
    "mail_smtpmode": "sendmail",
    "mail_smtpsecure": "ssl",
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "465",
    "mail_smtptimeout": 10,
    "mail_smtpauth": 0,
    "mail_smtpauthtype": "LOGIN",
    "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
    "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
    "maintenance": false,
    "integrity.check.disabled": false,
    "updater.release.channel": "stable",
    "enable_previews": true,
    "preview_Movie_path": "\/usr\/bin\/ffmpeg",
    "preview_ffmpeg_path": "\/usr\/bin\/ffmpeg",
    "enabledPreviewProviders": [
        "OC\\Preview\\PNG",
        "OC\\Preview\\JPEG",
        "OC\\Preview\\GIF",
        "OC\\Preview\\BMP",
        "OC\\Preview\\XBitmap",
        "OC\\Preview\\Movie",
        "OC\\Preview\\PDF",
        "OC\\Preview\\MP3",
        "OC\\Preview\\TXT",
        "OC\\Preview\\MarkDown",
        "OC\\Preview\\HEIC",
        "OC\\Preview\\OpenDocument",
        "OC\\Preview\\MSOffice2003",
        "OC\\Preview\\MSOfficeDoc",
        "OC\\Preview\\Image",
        "OC\\Preview\\Photoshop",
        "OC\\Preview\\SVG",
        "OC\\Preview\\Font",
        "OC\\Preview\\MKV",
        "OC\\Preview\\MP4",
        "OC\\Preview\\AVI",
        "OC\\Preview\\Movie",
        "OC\\Preview\\TIFF"
    ],
    "preview_max_x": 2048,
    "preview_max_y": 2048,
    "preview_max_memory": 4096,
    "preview_max_filesize_image": 256,
    "preview_max_scale_factor": 1,
    "trashbin_retention_obligation": "auto, 2",
    "loglevel": 3,
    "mail_sendmailmode": "smtp",
    "data-fingerprint": "A-FINGERPRINT",
    "onlyoffice": {
        "verify_peer_off": true,
        "jwt_header": "Authorization",
        "jwt_secret": "A-SECRET"
    },
    "encryption.legacy_format_support": false,
    "encryption.key_storage_migrated": false,
    "defaultapp": "dashboard",
    "theme": "",
    "allow_local_remote_servers": true,
    "files_external_allow_create_new_local": true,
    "app_install_overwrite": [
        "fulltextsearch",
        "fulltextsearch_elasticsearch",
        "files_fulltextsearch",
        "theming_customcss"
    ],
    "simpleSignUpLink.shown": false,
    "memories.exiftool": "\/var\/www\/nextcloud\/apps\/memories\/exiftool-bin\/exiftool-amd64-glibc",
    "memories.vod.path": "\/var\/www\/nextcloud\/apps\/memories\/exiftool-bin\/go-vod-amd64",
    "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
    "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
    "memories.gis_type": 2,
    "memories.vod.vaapi": true,
    "memories.exiftool_no_local": true,
    "session_keepalive": true
}

I switched over from unix socket to a tcp connection to loacal (127.0.0.1) redis server and get back into WebUI.

I had not found any hint why nextcloud was no longer able to connect to /run/redis/redis.sock

Please can anybody give me a hint what can cause a “block” or something else.
My www-data user was part of the redis group so the sock had redis:redis rw rights and has functioned for a long time no … until the latest php8.2-* updates for ubuntu.

Thanks for any help

With Update to 27.1.2 i tried at once the switch back to redis-server.sock instead the tcp:port connection to redis.

I switched back my settings as seen above but same login problem / session handler problem.

So i changed the following things:

a) in nextcloud/config/config.php i set

  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
  ),

b) in php/8.2/fpm/php.ini i set

[Session]
; Handler used to store/retrieve data.
; https://php.net/session.save-handler
#session.save_handler = files
session.save_handler = redis
#session.save_path = "tcp://127.0.0.1:6379?weight=1&database=10"
#-> alternatively see: https://github.com/phpredis/phpredis#php-session-handler
session.save_path = "unix:///var/run/redis/redis-server.sock?persistent=1&weight=1&database=0"
redis.session.locking_enabled = 1
redis.session.lock_retries = -1
redis.session.lock_wait_time = 10000

instead of just /var/run/redis.... i changed the line to
"unix:///var/run/redis/redis-server.sock?persistent=1&weight=1&database=0"

as described here
https://github.com/phpredis/phpredis#php-session-handler

In some posts in the www concerning redis.sock / unix sock communication an advice for
setting unix perm to 777 instead of 770 - but this wasn’t nescessary in my case.
(/etc/redis/redis.conf)

After a reboot of the whole server i was able to login again as expected with using redis-server.sock for phpsessions as well.

Maybe my investigations help others - running crazy to find what’s going wrong - in similar cases.
:slightly_smiling_face: