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
- Stop Redis:
docker stop nextcloud-stack-redis-1 - Delete corrupted AOF/RDB files:
sudo rm -rf ~/nextcloud-stack/redis_data/* - 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
- Run
lsas thewww-datauser inside the container: - If still empty, restart the container to refresh the bind mount:
- Ensure the NAS is mounted on the host before Docker starts (via
/etc/fstabwithx-systemd.automount).
docker exec -u www-data -it nextcloud-stack-nextcloud-1 ls -l /media/nas
docker restart nextcloud-stack-nextcloud-1
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
docker exec -u www-data -it nextcloud-stack-nextcloud-1 ls -l /media/nas
mount | grep nas_shareTakeaways
- 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 usesuid=33,gid=33in 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.
Comments
Post a Comment