RedisException: Connection Refused - Fedora Server, Podman, nginx

Nextcloud version: 27.0.0
Operating system and version: Fedora Server 38
nginx version: 3.18-d83940d6-ls8 (probably)
PHP version: 8.2


The issue you are facing:

I followed this guide to install Nextcloud 26. A few changes were made to the script and I went through an entire troubleshooting saga getting it to work, then optimizing it, then breaking it, then fixing it again.

Nextcloud 27 was released. I updated. Broke a bunch of things because I was an idiot. I ended up completely re-installing from scratch and got everything to a 99% functional state.

Everything works pretty much as it did before the update except for two things.

First, this warning on the admin page. I didn’t have Redis configured in NC26 and didn’t bother enabling it in my initial setup.

The database is used for transactional file locking. To enhance performance, please configure memcache, if available. See the documentation ↗ for more information.

This warning is new.

I installed Redis on the OS level and configured it as best I could figure based on the official example docs.

The warning cleared.

Tried opening a markdown file in the Files app. Got this error in the log:

[index] Error: RedisException: Connection refused at <<closure>>

 0. /config/www/nextcloud/lib/private/RedisFactory.php line 137
    Redis->pconnect()
 1. /config/www/nextcloud/lib/private/RedisFactory.php line 178
    OC\RedisFactory->create("*** sensitive parameters replaced ***")
 2. /config/www/nextcloud/lib/private/Memcache/Redis.php line 66
    OC\RedisFactory->getInstance()
 3. /config/www/nextcloud/lib/private/Memcache/Redis.php line 137
    OC\Memcache\Redis->getCache()
 4. /config/www/nextcloud/lib/private/Lock/MemcacheLockingProvider.php line 61
    OC\Memcache\Redis->inc()
 5. /config/www/nextcloud/lib/private/Files/Storage/Common.php line 765
    OC\Lock\MemcacheLockingProvider->acquireLock()
 6. /config/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 607
    OC\Files\Storage\Common->acquireLock()
 7. /config/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 607
    OC\Files\Storage\Wrapper\Wrapper->acquireLock()
 8. /config/www/nextcloud/lib/private/Files/View.php line 1917
    OC\Files\Storage\Wrapper\Wrapper->acquireLock()
 9. /config/www/nextcloud/lib/private/Files/View.php line 2030
    OC\Files\View->lockPath()
10. /config/www/nextcloud/lib/private/Files/View.php line 1123
    OC\Files\View->lockFile()
11. /config/www/nextcloud/lib/private/Files/View.php line 571
    OC\Files\View->basicOperation()
12. /config/www/nextcloud/lib/private/Files/Node/File.php line 54
    OC\Files\View->file_get_contents()
13. /config/www/nextcloud/apps/text/lib/Service/ApiService.php line 278
    OC\Files\Node\File->getContent()
14. /config/www/nextcloud/apps/text/lib/Service/ApiService.php line 134
    OCA\Text\Service\ApiService->loadContent()
15. /config/www/nextcloud/apps/text/lib/Controller/SessionController.php line 61
    OCA\Text\Service\ApiService->create("*** sensitive parameters replaced ***")
16. /config/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OCA\Text\Controller\SessionController->create("*** sensitive parameters replaced ***")
17. /config/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
18. /config/www/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
19. /config/www/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
20. /config/www/nextcloud/lib/base.php line 1064
    OC\Route\Router->match()
21. /config/www/nextcloud/index.php line 36
    OC::handleRequest()

PUT /apps/text/session/create
from 192.168.1.100 by REDACTED at 2023-06-14T02:21:12+00:00

I uninstalled Redis and made a Redis Podman container on the same Podman network as Nextcloud and MariaDB.

Warning cleared. Same errors in the log. RedisException: Connection refused

I tried changing the host and port variables on config.php, but that only gave me new errors:

	Redis::pconnect(): php_network_getaddresses: getaddrinfo for 10.0.89.0/24 failed: Try again at /config/www/nextcloud/lib/private/RedisFactory.php#137

and similar errors for every alternative host/port I tried.


config.php (causes RedisException error):

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
#  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => array(
     'host' => 'localhost',
     'port' => 6379,
     'timeout' => 0.0,
   ),
  'datadirectory' => '/data',
  'instanceid' => 'ochw2o86ewdd',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'REDACTED',
    1 => 'homelab:5011',
    2 => '192.168.1.120:5011',
  ),
  'default_phone_region' => 'US',
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'overwrite.cli.url' => 'https://REDACTED',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-db.dns.podman',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'mail_from_address' => 'REDACTED',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'outlook.com',
  'mail_smtphost' => 'smtp.office365.com',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'maintenance' => false,
);

My Podman run commands:
Nextcloud:

podman run -d \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=America/Los_Angeles \
-e MYSQL_HOST=nextcloud-db.dns.podman \
-e MYSQL_DATABASE=nextcloud \
-e MYSQL_USER=nextcloud \
-e MYSQL_PASSWORD=REDACTED \
-e NEXTCLOUD_ADMIN_USER=REDACTED \
-e NEXTCLOUD_ADMIN_PASSWORD=REDACTED \
-v nextcloud-app:/app:Z \
-v nextcloud-data:/data:Z \
-v nextcloud-config:/config:Z \
--network nextcloud-net \
--restart on-failure \
--name nextcloud-server-27 \
-p 5010:80 \
-p 5011:443 \
lscr.io/linuxserver/nextcloud:latest

MariaDB:

podman run --detach \
  -e MYSQL_DATABASE=nextcloud \
  -e MYSQL_USER=nextcloud \
  -e MYSQL_PASSWORD=REDACTED \
  -e MYSQL_ROOT_PASSWORD=REDACTED \
  -v nextcloud_test-db:/var/lib/mysql:Z \
  --network nextcloud-net \
  --restart on-failure \
  --name nextcloud_test-db \
  docker.io/library/mariadb:latest

Redis:

podman run -d \
--name redis-server \
--network nextcloud-net \
-p "6379:6379" \
-v redis-data:/data:Z \
-v /home/fern/redis/redis.conf:/usr/local/etc/redis/redis.conf:Z \
-e REDIS_REPLICATION_MODE=master \
docker.io/library/redis:latest

/var/log/nginx/error.log:

Nothing!

Apps installed:


Activity
2.19.0

Auditing / Logging
1.17.0

Brute-force settings
2.7.0

Calendar
4.4.2

Circles
27.0.0

Collaborative tags
1.17.0

Comments
1.17.0

Contacts
5.3.0

Contacts Interaction
1.8.0

Dashboard
7.7.0

Deleted files
1.17.0

External storage support
1.19.0

Federation
1.17.0

File sharing
1.19.0

Files automated tagging
1.17.0

First run wizard
2.16.0

Impersonate
1.14.0

Log Reader
2.12.0

Monitoring
1.17.0

Nextcloud announcements
1.16.0

Notes
4.8.0

Notifications
2.15.0

Password policy
1.17.0

PDF viewer
2.8.0

Photos
2.3.0

Privacy
1.11.0

Recommendations
1.6.0

Related Resources
1.2.0

Right click
1.6.0

Share by mail
1.17.0

Support
1.10.0

Suspicious Login
5.0.0

Talk
17.0.0

Tasks
0.15.0

Text
3.8.0

Two-Factor WebAuthn
1.2.0

Update notification
1.17.0

Usage survey
1.15.0

User status
1.7.0

Versions
1.20.0

Weather status 
1.7.0

To be clear, if I simply don’t configure Redis, everything works except for that sole warning about transactional file locking.
If I do configure Redis, the warning clears, but I can’t access any files.

Best I can figure, it’s a permissions error, but whether it has to do with Fedora, SELinux, Podman, or… something else, I’m reaching the limits of my knowledge and experience and I can’t figure it out.

Let me know if there’s anything else I should include.

Thanks in advance for any help!
LittleWhiteFern

So, I did eventually have a brainwave that worked out.
A simpler Redis container on the same subnetwork as the Nextcloud container:

podman run --detach \
  --name nextcloud-redis \
  --network nextcloud-net \
  --restart on-failure \
  docker.io/library/redis:latest

Setting the Redis host in config.php to nextcloud-redis.dns.podman gave me a working Redis cache.

Hope this helps anyone who decides to try this very non-standard installation