Fixing Nextcloud Redis Errors and NAS Mount Issues in Docker


Running Nextcloud in Docker is convenient, but sometimes you’ll hit errors with Redis caching or NAS mounts. In this post, I’ll walk through how I fixed two common problems:

  • Redis crashing with append-only file corruption
  • NAS mount not showing inside the Nextcloud container

1. Redis Error: php_network_getaddresses / Connection Refused

My Nextcloud logs were full of errors like:

php_network_getaddresses: getaddrinfo for redis failed: Name or service not known
RedisException: Connection refused

Checking containers:

docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}"

revealed that nextcloud-stack-redis-1 kept restarting. Logs showed:

Bad file format reading the append only file appendonly.aof.3.incr.aof
make a backup of your AOF file, then use ./redis-check-aof --fix

Solution

  1. Stop Redis: docker stop nextcloud-stack-redis-1
  2. Delete corrupted AOF/RDB files: sudo rm -rf ~/nextcloud-stack/redis_data/*
  3. Restart Redis: docker start nextcloud-stack-redis-1

This cleared the corruption, Redis came up cleanly, and Nextcloud could connect again. In config/config.php make sure Redis is configured properly:

'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
  'host' => 'redis',
  'port' => 6379,
],

2. NAS Not Visible Inside Container

In my docker-compose.yml I had:

- /mnt/nas_share:/media/nas

But inside the Nextcloud container, the folder looked empty:

docker exec -it nextcloud-stack-nextcloud-1 ls -l /media/nas
total 0

On the host, files were there but owned by www-data with restrictive permissions:

drwxrwx--- 2 www-data www-data 0 Aug  5 01:25 Backup Server 1

Solution

  1. Run ls as the www-data user inside the container:
  2. docker exec -u www-data -it nextcloud-stack-nextcloud-1 ls -l /media/nas
  3. If still empty, restart the container to refresh the bind mount:
  4. docker restart nextcloud-stack-nextcloud-1
  5. Ensure the NAS is mounted on the host before Docker starts (via /etc/fstab with x-systemd.automount).

3. Make NAS Mount Persistent (fstab)

To ensure the NAS is always available before Docker starts, add an entry to /etc/fstab. Examples:

CIFS / SMB Share (Windows-style)

//nas-server/share  /mnt/nas_share  cifs  credentials=/root/.nas-credentials,uid=33,gid=33,file_mode=0770,dir_mode=0770,nounix,iocharset=utf8,noperm,x-systemd.automount  0  0

Create a credentials file at /root/.nas-credentials:

username=yourusername
password=yourpassword
domain=YOURDOMAIN

NFS Share

nas-server:/export/share  /mnt/nas_share  nfs  rw,sync,hard,intr,x-systemd.automount  0  0

After editing /etc/fstab, reload with:

sudo systemctl daemon-reexec
sudo mount -a

4. Troubleshooting Checklist

If something still doesn’t work, here are some quick commands to verify:

  • Check if Redis is running: docker ps | grep redis
  • View Redis logs: docker logs --tail 50 nextcloud-stack-redis-1
  • Test Redis from inside Nextcloud container:
  • docker exec -it nextcloud-stack-nextcloud-1 redis-cli -h redis ping
    # should return PONG
  • List NAS directory as www-data inside container:
  • docker exec -u www-data -it nextcloud-stack-nextcloud-1 ls -l /media/nas
  • Verify mount is active on host: mount | grep nas_share

Takeaways

  • If Redis keeps restarting in Docker, corrupted AOF files are often the cause. Wipe them if Redis is only used as a cache.
  • Bind mounts reflect host folders exactly. If your NAS isn’t mounted before Docker starts, the container will see an empty folder.
  • Permissions matter: Nextcloud runs as www-data, so make sure your NAS mount uses uid=33,gid=33 in fstab.

Support My Work

If this blog post helped you, please consider a small donation. Your support helps keep this content free and accessible for everyone. Thank you!

Donate with PayPal

The easiest way to support me is by buying me a coffee through PayPal. It's quick, secure, and uses a trusted platform.

Buy Me a Coffee! or a new Macbook!

Donate with Crypto

You can also support me with cryptocurrency. Just copy the address of your preferred coin below.

Bitcoin
31kpUFfNo8SSq5jidTY9Eihyb9qJS4FPP2
Ethereum
0x32fB1E082EB566bBbca3137a5a17a92db9C880F7
XRP
rsRy14FvipgqudiGmptJBhr1RtpsgfzKMM
XRP Tag
3802858062

Comments

Popular posts from this blog

Self-Hosted Personal Cloud: From Old Laptop to Fully Private Cloud

How to Download AnyFlip Books as PDFs with Anyflip Downloader

Mastering WordPress Multisite in cPanel: A Complete Guide