[SOLVED] Can't get redis to work in socket mode

Nextcloud version: 22.1.1
Operating system and version: Rocky Linux 8.4 (basically centos8/rhel8)
Apache or nginx version: Apache/2.4.37 (rocky)
PHP version: PHP 7.4.23


Hello!

The issue I am facing:
Redis ONLY works if default configuration is used, aka: “localhost” & “port 6379”. (both set in nextcloud config and redis config)

If I try to change to socket, or change the port from 6379 to 6479 (for example), server stops working (cant access web interface).

I always reboot the entire server when changing redis configuration.

I have verified that when I tried using a socket, redis worked and user apache could access it by running the command:

sudo -u apache redis-cli -s /run/redis/redis.sock ping

reply was: PONG

Yet the nc server stops working…

As said the nextcloud server works if I use redis configured for localhost:6379 so the (is it called websocket?) port listening seems to work?, UNLESS I change the port, then the server stops working.

In other words, ONLY the DEFAULT configuration of redis works with nextcloud for me.


Is this the first time you’ve seen this error? (Y/N): YES (however redis seems to be a problem for many)

Steps to replicate it:

  1. Install redis & php-pecl-redis (also systemctl enable redis)
  2. Configure nextcloud config and redis config to use a socket according to the docs.
  3. reboot
  4. Nextcloud does not work, can’t access web interface.
    .
  5. Change both configurations to use “localhost:6379”
  6. Nextcloud works as expected, no related errors so far.
    .
  7. Change config again to “localhost:6479”
  8. Nextcloud does not work again.

The output of my Nextcloud log in Admin > Logging (this is from trying to start in socket mode):

{"reqId":"YS07UJ0vWcfg3SrEiYrY9AAAAIE","level":3,"time":"2021-08-30T20:10:56+00:00","remoteAddr":"192.168.1.46","user":"--","app":"index","method":"GET","url":"/","message":"Permission denied","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"22.1.1.2","exception":{"Exception":"RedisException","Message":"Permission denied","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/RedisFactory.php","line":124,"function":"connect","class":"Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/RedisFactory.php","line":164,"function":"create","class":"OC\\RedisFactory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Memcache/Redis.php","line":43,"function":"getInstance","class":"OC\\RedisFactory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Memcache/Factory.php","line":115,"function":"__construct","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":1051,"function":"createLocking","class":"OC\\Memcache\\Factory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":2010,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Files/View.php","line":118,"function":"getLockingProvider","class":"OC\\Server","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":433,"function":"__construct","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":1373,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":594,"function":"boot","class":"OC\\Server","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1083,"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/lib/private/RedisFactory.php","Line":124,"CustomMessage":"--"}}
{"reqId":"YS07UJ0vWcfg3SrEiYrY9AAAAIE","level":3,"time":"2021-08-30T20:10:56+00:00","remoteAddr":"192.168.1.46","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not boot files_trashbin: Could not resolve trashManager! Class trashManager does not exist","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"22.1.1.2","exception":{"Exception":"OCP\\AppFramework\\QueryException","Message":"Could not resolve trashManager! Class trashManager does not exist","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":131,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":161,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":435,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php","line":57,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"function":"OC\\AppFramework\\Bootstrap\\{closure}","class":"OC\\AppFramework\\Bootstrap\\FunctionInjector","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php","line":67,"function":"array_map"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/BootContext.php","line":51,"function":"injectFn","class":"OC\\AppFramework\\Bootstrap\\FunctionInjector","type":"->"},{"file":"/var/www/html/nextcloud/apps/files_trashbin/lib/AppInfo/Application.php","line":56,"function":"injectFn","class":"OC\\AppFramework\\Bootstrap\\BootContext","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":178,"function":"boot","class":"OCA\\Files_Trashbin\\AppInfo\\Application","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":205,"function":"bootApp","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":139,"function":"loadApp","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/apps/dav/lib/AppInfo/Application.php","line":168,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":178,"function":"boot","class":"OCA\\DAV\\AppInfo\\Application","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":205,"function":"bootApp","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":139,"function":"loadApp","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Util.php","line":204,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/Files/Filesystem.php","line":244,"function":"setupFS","class":"OC_Util","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":411,"function":"getMountManager","class":"OC\\Files\\Filesystem","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":444,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/Files/Node/LazyFolder.php","line":62,"function":"call_user_func"},{"file":"/var/www/html/nextcloud/lib/private/Files/Node/LazyFolder.php","line":142,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Files/AppData/AppData.php","line":141,"function":"get","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSCombiner.php","line":96,"function":"getFolder","class":"OC\\Files\\AppData\\AppData","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSResourceLocator.php","line":115,"function":"process","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSResourceLocator.php","line":71,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":374,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":202,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Template.php","line":182,"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/private/legacy/OC_Template.php","line":331,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/html/nextcloud/index.php","line":74,"function":"printExceptionErrorPage","class":"OC_Template","type":"::"}],"File":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","Line":120,"CustomMessage":"Could not boot files_trashbin: Could not resolve trashManager! Class trashManager does not exist"}}
{"reqId":"YS07UJ0vWcfg3SrEiYrY9AAAAIE","level":3,"time":"2021-08-30T20:10:56+00:00","remoteAddr":"192.168.1.46","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not boot files_versions: Could not resolve OCA\\Files_Versions\\Versions\\IVersionManager! Class can not be instantiated","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"22.1.1.2","exception":{"Exception":"OCP\\AppFramework\\QueryException","Message":"Could not resolve OCA\\Files_Versions\\Versions\\IVersionManager! Class can not be instantiated","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":131,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":460,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":432,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->"},{"file":"/var/www/html/nextcloud/apps/files_versions/lib/AppInfo/Application.php","line":121,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/apps/files_versions/lib/AppInfo/Application.php","line":108,"function":"loadBackend","class":"OCA\\Files_Versions\\AppInfo\\Application","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php","line":67,"function":"registerVersionBackends","class":"OCA\\Files_Versions\\AppInfo\\Application","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/BootContext.php","line":51,"function":"injectFn","class":"OC\\AppFramework\\Bootstrap\\FunctionInjector","type":"->"},{"file":"/var/www/html/nextcloud/apps/files_versions/lib/AppInfo/Application.php","line":93,"function":"injectFn","class":"OC\\AppFramework\\Bootstrap\\BootContext","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":178,"function":"boot","class":"OCA\\Files_Versions\\AppInfo\\Application","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":205,"function":"bootApp","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":139,"function":"loadApp","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/apps/dav/lib/AppInfo/Application.php","line":168,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":178,"function":"boot","class":"OCA\\DAV\\AppInfo\\Application","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":205,"function":"bootApp","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":139,"function":"loadApp","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Util.php","line":204,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/Files/Filesystem.php","line":244,"function":"setupFS","class":"OC_Util","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":411,"function":"getMountManager","class":"OC\\Files\\Filesystem","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":444,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/Files/Node/LazyFolder.php","line":62,"function":"call_user_func"},{"file":"/var/www/html/nextcloud/lib/private/Files/Node/LazyFolder.php","line":142,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Files/AppData/AppData.php","line":141,"function":"get","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSCombiner.php","line":96,"function":"getFolder","class":"OC\\Files\\AppData\\AppData","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSResourceLocator.php","line":115,"function":"process","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSResourceLocator.php","line":71,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":374,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":202,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Template.php","line":182,"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/private/legacy/OC_Template.php","line":331,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/html/nextcloud/index.php","line":74,"function":"printExceptionErrorPage","class":"OC_Template","type":"::"}],"File":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","Line":116,"CustomMessage":"Could not boot files_versions: Could not resolve OCA\\Files_Versions\\Versions\\IVersionManager! Class can not be instantiated"}}
{"reqId":"YS07UJ0vWcfg3SrEiYrY9AAAAIE","level":3,"time":"2021-08-30T20:10:56+00:00","remoteAddr":"192.168.1.46","user":"--","app":"core","method":"GET","url":"/","message":"Permission denied","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"22.1.1.2","exception":{"Exception":"RedisException","Message":"Permission denied","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/RedisFactory.php","line":124,"function":"connect","class":"Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/RedisFactory.php","line":164,"function":"create","class":"OC\\RedisFactory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Memcache/Redis.php","line":43,"function":"getInstance","class":"OC\\RedisFactory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Memcache/Factory.php","line":115,"function":"__construct","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":1051,"function":"createLocking","class":"OC\\Memcache\\Factory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":2010,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Files/View.php","line":118,"function":"getLockingProvider","class":"OC\\Server","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":433,"function":"__construct","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":1373,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":594,"function":"boot","class":"OC\\Server","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1083,"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/lib/private/RedisFactory.php","Line":124,"CustomMessage":"--"}}
{"reqId":"YS07UJ0vWcfg3SrEiYrY9AAAAIE","level":3,"time":"2021-08-30T20:10:56+00:00","remoteAddr":"192.168.1.46","user":"--","app":"core","method":"GET","url":"/","message":"Redis server went away","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0","version":"22.1.1.2","exception":{"Exception":"RedisException","Message":"Redis server went away","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Memcache/Redis.php","line":55,"function":"get","class":"Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSCombiner.php","line":122,"function":"get","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSCombiner.php","line":102,"function":"isCached","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSResourceLocator.php","line":115,"function":"process","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSResourceLocator.php","line":71,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":374,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":202,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Template.php","line":182,"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/private/legacy/OC_Template.php","line":331,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/html/nextcloud/index.php","line":74,"function":"printExceptionErrorPage","class":"OC_Template","type":"::"}],"File":"/var/www/html/nextcloud/lib/private/Memcache/Redis.php","Line":55,"CustomMessage":"--"}}
{"reqId":"8HzxSmwwxBIs10yZSFQ2","level":3,"time":"2021-08-30T20:15:01+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Connection refused","userAgent":"--","version":"22.1.1.2","exception":{"Exception":"RedisException","Message":"Connection refused","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/RedisFactory.php","line":124,"function":"connect","class":"Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/RedisFactory.php","line":164,"function":"create","class":"OC\\RedisFactory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Memcache/Redis.php","line":43,"function":"getInstance","class":"OC\\RedisFactory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Memcache/Factory.php","line":115,"function":"__construct","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":1051,"function":"createLocking","class":"OC\\Memcache\\Factory","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":2010,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Files/View.php","line":118,"function":"getLockingProvider","class":"OC\\Server","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":433,"function":"__construct","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":160,"function":"OC\\{closure}","class":"OC\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php","line":118,"function":"OC\\AppFramework\\Utility\\{closure}","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":127,"function":"offsetGet","class":"Pimple\\Container","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/ServerContainer.php","line":136,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Server.php","line":1373,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":594,"function":"boot","class":"OC\\Server","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1083,"function":"init","class":"OC","type":"::"},{"file":"/var/www/html/nextcloud/cron.php","line":42,"args":["/var/www/html/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/lib/private/RedisFactory.php","Line":124,"CustomMessage":"--"}}

The output of my config.php file in /path/to/nextcloud (with the settings for redis in socket mode):

$CONFIG = array (
  'instanceid' => '***********',
  'passwordsalt' => '***********',
  'secret' => ***********',
  'trusted_domains' =>
  array (
    0 => '192.168.1.35',
    1 => '***********',
    2 => '***********',
  ),
  'datadirectory' => '/opt/datastor/nc_data/',
  'dbtype' => 'mysql',
  'version' => '22.1.1.2',
  'overwrite.cli.url' => 'http://192.168.1.35',
  'dbname' => '***********',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '***********',
  'dbpassword' => '***********',
  'installed' => true,
  'log_type' => 'file',
  'loglevel' => 3,
  'default_phone_region' => 'SE',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'memcache.locking' => '\OC\Memcache\Redis',
  'filelocking.enabled' => 'true',
  'redis' => array (
     'host'     => '/run/redis/redis.sock',
     'port'     => 0,
  ),
  'updater.secret' => '***********',
  'maintenance' => false,
  'theme' => '',
);

The output of my redis.conf in /etc/redis.conf (with the settings for redis in socket mode):

#I removed all commented lines for this post.

bind 127.0.0.1
protected-mode yes
port 0
tcp-backlog 511
unixsocket /run/redis/redis.sock
unixsocketperm 770
timeout 0
tcp-keepalive 300
daemonize yes
#Below this nothing was changed, all default values.

Output of /etc/group (as said earlier "ping"ing redis as user apache returns “pong”, so should work, right?):

...
redis:x:992:apache

Permissions for /run/redis/redis.sock seem as they should, and if i remember correctly i even did some chmod on the redis log file following some other help.nextcloud post to 770.

I have made no progress past this in solving the issue.

Could it be some deepgoing SELinux issue? I really have no idea how to proceed…

Any help appriciated!

did you check selinux?

1 Like

I turned of SELinux with # setenforce 0, changed configs and restarted httpd and redis daemons, and would you look at that, running redis in socket now works!

So it is a fault of SELinux… How do I configure SELinux to work with sockets without disabling the entire thing/setting it to permissive? Or rather, what is the minimum change to sel policy that allows me to run redis in socket mode?

Take a look here (below section: IF you’re running Redis as a UNIX socket (i.e. using Port 0 and you set unixsocket and unixsocketperm in /etc/redis.conf) then try the following on the Linux command line to generate a permissive SELinux policy that allows Apache or Nginx to read and write to the Redis unix socket…)

1 Like

BTW, you need permissions for every element in the file path. That is, you need x permission on /run and /run/redis.

Also, redis has a --unixsocketperm option to tell what permission to use when creating the socket file, and --unixsocket to tell it to put the socket file somewhere else. I seem to recall that the redis docker image restricts /run/redis in a way I could not get around.

Sorry for late reply, this does indeed solve the problem, using the audit is smart and sounds like the smallest change needed in SELinux policy, awesome!

Could you expand on what the first setting setsebool -P daemons_enable_cluster_mode 1 does? I can’t find/don’t understand what it does/why it is necessary…

Also is there a way to see concretely what the httpd-to-redis-socket policy does?

Only wish to learn and understand further.

Thank you for your time! Helps a lot!

Some cluster resources need selinux boolean ‘daemons_enable_cluster_mode’ to be enabled in order to start. This is also true for Redis for both local server cache and file locking and Redis is configured to listen on a Unix socket. It allows daemons to manage cluster lib files.

If you want to check the status of the SELinux booleans on your machine type:

$ getsebool -a

This simply allows Apache/Nginx (httpd) to connect to the Redis socket.

Not helping you with selinux, but in general i run to the same problem with ubuntu 20 server without selinux.

I finally find out that you should change /etc/redis/redis.conf
unixsocketperm 700 to
unixsocketperm 770
so that www-data group user can access redis-server.sock , in documentation that is not mentioned.
https://docs.nextcloud.com/server/21/admin_manual/configuration_server/caching_configuration.html

If you take a closer look at @Rinkana redis.conf snippet within the OP you might notice that the setting for unixsocketperm is indeed already set to 770 there :wink:

As a sidenote: On our Ubuntu 18.04 servers we have set unixsocketperm to 700 and they are all working flawlessly with Apache and Redis listening on a Unix socket. We are not running redis as a daemon though (daemonize no) thus Redis does not not need to write its pid file into /var/run.

This is also true for Redis for both local server cache and file locking and Redis is configured to listen on a Unix socket.

Sorry if this is a dumb question but what makes redis a clustered resource? Is it that the file locking + transactional cache makes two clustered processes or? Wouldn’t this mean that daemons_enable_cluster_mode needs to be turned on even when redis is run trough tcp? i.e in my case it has to be turned on by default (since it worked with default config)?

As a sidenote: On our Ubuntu 18.04 servers we have set unixsocketperm to 700 and they are all working flawlessly with Apache and Redis listening on a Unix socket.

Doesn’t this need that the socket file is owned by both the apache and reddis user at the same time? How does that even work? Since 700 only gives permissions to owner but none to the group?

Actually since we are using Redis on a single box with NC it isn’t and therefore cluster-enabled defaults to no. Why CentOS / RHEL 7 and related operating systems using SELinux insist on that setting is beyond my scope. As for Debian based operating systems that setting is not necessary.

Yup

  • owner: redis
  • group: www-data (as for Ubuntu)

Maybe I get your post wrong. But afaik the www-data user has to be added to the redis group and the socket file should still be owned by the redis user and group. Like this…

usermod -aG redis www-data

and then you would need to set the unixsocketperm to 770 in order to give www-data permissions…

7 (Read/write/execute permissions) for the user (redis).
7 (Read/write/execute permissions) for the group (redis) to which the www-data user has been added.
0 (no permissions) for Public/others

That’s at least how I run it.

Sorry in the haste I forgot about that one. Though we usually make the redis user a member of the www-data group:

$ usermod -g www-data redis

with 755 on the rundir (/var/run/redis-nextcloud) and 700 for the socket file itself (redis-server-nc.sock in our case since we are running multiple redis instances for different services on our servers).

But obviously either way works.

Thank you for pointing this out, @bb77 :+1:t3:

1 Like