Terminal showing Docker containers running Nextcloud, MariaDB, and Redis in a homelab environment

How to Install Nextcloud with Docker (Self-Hosted Cloud Storage)

Why You Should Own Your Files

I run Nextcloud in my homelab. It replaced Google Drive, Dropbox, and iCloud across every device in my household. The honest version of that story is that it took me two attempts to get it right, and there were weeks where I genuinely considered going back to Google. Nextcloud is powerful, configurable, and mature. It is also the single most maintenance-heavy service in my entire stack.

From the homelab: I replaced Google Drive, Calendar, and Contacts with Nextcloud. It runs on my Proxmox cluster and handles everything from file sync to shared calendars across all my devices. It is one of the first services I recommend to anyone starting their self-hosting journey.

I am telling you this upfront because every other Nextcloud tutorial makes it sound like a quick Docker pull and you are done. You are not. What you are doing is becoming your own cloud provider, and that comes with responsibilities: updates that break plugins, sync conflicts on mobile, cron jobs that silently stop running, and performance issues that creep in as your file count grows. I would still make the same choice today, but I want you going in with your eyes open.

This guide covers a production-grade Nextcloud deployment with Docker Compose, MariaDB, and Redis, not the SQLite demo setup that falls over the moment you add a second user. I will cover the performance tuning, backup strategy, and maintenance reality that most guides conveniently skip.

Tested on: Ubuntu Server 24.04 with Docker Engine from Docker’s apt repository, Nextcloud 35.0.3 (nextcloud:35), MariaDB 11 and Redis 7, with Caddy as the HTTPS front, in the ReadTheManual lab on 15 November 2026. The passwords in the screenshots are the placeholders from this guide.

The Short Version

Three containers from one Compose file (Step 2), docker compose up -d (Step 3), HTTPS in front of it (Step 4), then a Redis check, a cron line and a backup script (Step 5 and Backup Strategy). Get the backup script right before you trust the install: the version most people write fails when run as a normal user, because config.php belongs to the web server account, and with set -e it stops while Nextcloud is still in maintenance mode, so every user sees the maintenance page until someone notices. The script in this guide runs with sudo and switches maintenance mode off however it ends, and the lab run below shows both the failure and the recovery.

The Nextcloud stack in this guide: three containers (Nextcloud, MariaDB, Redis), the reverse proxy in front, the cron line and the backup script
The Nextcloud stack in this guide: three containers (Nextcloud, MariaDB, Redis), the reverse proxy in front, the cron line and the backup script.

Prerequisites

Before you start, you will need:

  • Docker and Docker Compose installed on your server. If you have not done this yet, follow the Docker installation guide for Ubuntu 24.04.
  • A reverse proxy handling TLS termination. Nginx Proxy Manager is the easiest option, and Caddy or Traefik work too. Nextcloud needs HTTPS to function properly: the mobile and desktop sync clients will complain or refuse to connect over plain HTTP.
  • A domain name pointing to your server (e.g., cloud.yourdomain.com). A free DuckDNS subdomain works if you do not own a domain.
  • At least 2 GB of RAM free for the Nextcloud stack, and sufficient storage for your files. Nextcloud itself is small, but your data is not. Plan for where your files will actually live.

If you are planning to store a significant amount of data (photos, documents, media), consider mounting an external drive or NAS share for the Nextcloud data directory rather than using the boot disk. I learned this the hard way when my 256 GB NVMe filled up with family photos inside two months. Separate your OS storage from your data storage.

Step 1: Create the Project Directory

Keep things organised from the start. Create a dedicated directory for your Nextcloud deployment:

mkdir -p ~/nextcloud && cd ~/nextcloud

Step 2: Create the Docker Compose File

This is a three-container deployment: Nextcloud (the application), MariaDB (the database), and Redis (the memory cache). Do not use SQLite for anything beyond testing. It does not handle concurrent access, and you will hit locking issues the moment two devices try to sync simultaneously.

Create docker-compose.yml:

services:
  nextcloud:
    image: nextcloud:35   # pin the major version; see the upgrade note below
    container_name: nextcloud
    restart: unless-stopped
    depends_on:
      - db
      - redis
    environment:
      - MYSQL_HOST=db
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - REDIS_HOST=redis
      - REDIS_HOST_PASSWORD=${REDIS_PASSWORD}
      - PHP_MEMORY_LIMIT=1024M
      - PHP_UPLOAD_LIMIT=10G
      - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
      - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
      - NEXTCLOUD_TRUSTED_DOMAINS=${NEXTCLOUD_DOMAIN}
      - OVERWRITEPROTOCOL=https
      - OVERWRITECLIURL=https://${NEXTCLOUD_DOMAIN}
    volumes:
      - ./html:/var/www/html
      - ./data:/var/www/html/data
    ports:
      - "8080:80"

  db:
    image: mariadb:11
    container_name: nextcloud-db
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - ./db:/var/lib/mysql

  redis:
    image: redis:7-alpine
    container_name: nextcloud-redis
    restart: unless-stopped
    command: redis-server --requirepass ${REDIS_PASSWORD}
    volumes:
      - ./redis:/data

Now create the .env file for your secrets:

NEXTCLOUD_DOMAIN=cloud.yourdomain.com
NEXTCLOUD_ADMIN_USER=admin
NEXTCLOUD_ADMIN_PASSWORD=ChangeMeToSomethingStrong
MYSQL_PASSWORD=AnotherStrongPassword
MYSQL_ROOT_PASSWORD=YetAnotherStrongPassword
REDIS_PASSWORD=RedisPasswordHere
Step 2: the .env file from the guide (placeholder passwords, domain set to the lab's address, masked) and the three services in the Compose file: Nextcloud 35, MariaDB 11 and Redis 7
Step 2: the .env file from the guide (placeholder passwords, domain set to the lab’s address, masked) and the three services in the Compose file: Nextcloud 35, MariaDB 11 and Redis 7.

For a quick test without a domain name you can put the server’s own address in NEXTCLOUD_DOMAIN, as the lab did. Whatever you put there is the only name Nextcloud will accept at first (see Troubleshooting), so browse to that same name later.

Pin the Nextcloud major version. Nextcloud can only be upgraded one major version at a time (33 to 34, then 34 to 35). The container upgrades itself on start when the image is newer than your data, so an unpinned nextcloud:latest that jumps two majors in one pull leaves you with an install that refuses to upgrade. Pin a major tag as above, and when you move up, change it by one major, start the container, let the upgrade finish, and repeat. The tag shown was the current major when this was written; use whichever major you install.

That MariaDB command flag (--transaction-isolation=READ-COMMITTED) is not optional. Nextcloud requires READ-COMMITTED isolation to avoid deadlocks during file operations. (Older examples also added --log-bin=binlog --binlog-format=ROW; the current Nextcloud Docker example no longer includes them.) Skip them and you will get database lock errors under any real usage. This is one of the most common issues in Nextcloud Docker deployments and the cause is almost always a missing MariaDB configuration.

Step 3: Start the Stack

docker compose up -d
Step 3: docker compose up -d pulls the three images and starts the stack
Step 3: docker compose up -d pulls the three images and starts the stack.

Watch the logs to make sure everything starts cleanly:

docker compose logs -f
The Nextcloud container log after the first start (last lines)
The Nextcloud container log after the first start (last lines).

The first start takes a minute or two as Nextcloud runs its database migrations and creates the admin account. You should see messages about database tables being created. If you see connection refused errors for MariaDB, the database container might not be ready yet. Nextcloud will retry, so give it a moment. When docker compose ps shows all three containers up, status.php reports "installed":true and the version:

curl -s http://localhost:8080/status.php
docker compose ps once the first start has finished, and Nextcloud's own status.php (installed, version)
docker compose ps once the first start has finished, and Nextcloud’s own status.php (installed, version).

Once it settles, Nextcloud will be accessible on http://your-server-ip:8080. Do not log in yet: set up your reverse proxy first.

Step 4: Configure Your Reverse Proxy

If you are using Nginx Proxy Manager:

  1. Create a new proxy host for cloud.yourdomain.com
  2. Point it to your server’s IP on port 8080
  3. Enable SSL with a Let’s Encrypt certificate
  4. Turn on Force SSL and HTTP/2

There is one extra step that catches everyone out. Nextcloud needs certain headers passed through correctly. In the Advanced tab of your proxy host, add:

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 10G;
proxy_request_buffering off;

That client_max_body_size line is critical on plain Nginx, which defaults to a 1 MB upload limit, and you will get cryptic errors when syncing anything larger. (Nginx Proxy Manager already ships with a 2000 MB limit, so there it only matters for files bigger than that.) Set it to something reasonable for your use case. I use 10 GB because I sync video files occasionally.

Step 5: First Login and Essential Configuration

Navigate to https://cloud.yourdomain.com, the same name you put in NEXTCLOUD_DOMAIN, and log in with the admin credentials from your .env file. An IP address or any other name gets the untrusted-domain error instead (see Troubleshooting).

The Nextcloud login page over HTTPS, reached by the address in NEXTCLOUD_DOMAIN (the lab address, masked)
The Nextcloud login page over HTTPS, reached by the address in NEXTCLOUD_DOMAIN (the lab address, masked).

The first login shows a welcome dialog (skip it) and lands on the dashboard. Open Files and you will find Nextcloud’s sample folders and files already there:

The Files view straight after the first login as the admin user: Nextcloud's sample Documents, Photos and Templates folders and files, 62.6 MB used (the recent-files strip also shows a few made-up lab test files)
The Files view straight after the first login as the admin user: Nextcloud’s sample Documents, Photos and Templates folders and files, 62.6 MB used (the recent-files strip also shows a few made-up lab test files).

Anything you upload, from the web or a sync client, lands here. The lab put a made-up picture in Photos with a WebDAV upload (Step 6 shows the address), and it shows up next to the samples:

Inside the Photos folder: the sample photos plus beach-day.png, a made-up picture uploaded over WebDAV for this lab
Inside the Photos folder: the sample photos plus beach-day.png, a made-up picture uploaded over WebDAV for this lab.

Before you start uploading files, there are several settings to configure.

Check Redis caching

You do not need to edit config.php for Redis. When REDIS_HOST and REDIS_HOST_PASSWORD are set, the official image writes the Redis settings for the distributed cache and file locking itself, and APCu is already configured as the local cache. Confirm it took:

docker exec -u www-data nextcloud php occ config:system:get memcache.distributed
docker exec -u www-data nextcloud php occ config:system:get memcache.locking
Step 5, checking Redis caching with occ: memcache.distributed and memcache.locking both report the Redis class
Step 5, checking Redis caching with occ: memcache.distributed and memcache.locking both report the Redis class.

Both should print \OC\Memcache\Redis. If REDIS_HOST_PASSWORD is missing while Redis requires a password, Nextcloud logs authentication errors and pages fail to load, so check that variable first.

Set up the cron job

Nextcloud needs a background task runner. The default is AJAX (runs when someone opens the browser), which is unreliable. Switch to system cron.

In the Nextcloud admin panel, go to Administration Settings > Basic settings and select Cron as the background jobs method. The page also says when the last job ran, which is the quickest way to see that cron is working. Nextcloud’s background jobs documentation explains the three methods.

Then set up the actual cron job on your host:

crontab -e
# Add this line:
*/5 * * * * docker exec -u www-data nextcloud php cron.php
Setting up the cron job from the guide (the line added to the user's crontab, listed with crontab -l) and running it once by hand
Setting up the cron job from the guide (the line added to the user’s crontab, listed with crontab -l) and running it once by hand.

If you run cron.php by hand in the first minute after the first start it can exit with an error while the first-start jobs settle (it did once in the lab; the same command exited 0 a few minutes later), so wait and run it again. Once it has run, the Basic settings page shows Cron selected and when the last job ran:

Administration settings, Basic settings, Background jobs: Cron is selected and the page reports when the last job ran. In the lab this was already the case after cron.php had been run once from the command line
Administration settings, Basic settings, Background jobs: Cron is selected and the page reports when the last job ran. In the lab this was already the case after cron.php had been run once from the command line.

This runs Nextcloud’s background tasks every five minutes. Without it, file scanning, cleanup jobs, and notification emails will not work properly. This is one of the most commonly missed steps, and the symptoms are subtle: things just feel slow and slightly broken without an obvious error.

Configure email

Go to Administration Settings > Basic settings and set up SMTP for email notifications. Nextcloud sends share notifications, password resets, and activity digests via email. Without SMTP configured, shared links will not send notification emails and password resets will silently fail.

Step 6: Adding Users and Connecting Devices

Go to Accounts (called Users before Nextcloud 28) in the top-right menu to create accounts for family members or housemates. Set storage quotas per user if you need to manage disk space.

For sync clients, Nextcloud has apps for every platform:

  • Desktop: Download the Nextcloud client for Windows, macOS, or Linux from nextcloud.com
  • Mobile: Install from the App Store (iOS) or Google Play (Android)
  • WebDAV: Any WebDAV client can connect using https://cloud.yourdomain.com/remote.php/dav/files/USERNAME/

You can check that address from the command line. Here a PROPFIND on the admin account’s Photos folder lists the made-up beach-day.png, which was uploaded with a WebDAV PUT:

Step 6, WebDAV: the remote.php/dav/files/USERNAME/ address from the guide answers a PROPFIND; the listing of the Photos folder shows the made-up beach-day.png uploaded this way
Step 6, WebDAV: the remote.php/dav/files/USERNAME/ address from the guide answers a PROPFIND; the listing of the Photos folder shows the made-up beach-day.png uploaded this way.

On first connection, point the client to your domain, log in, and choose which folders to sync. I recommend selective sync rather than syncing everything: your phone does not need a copy of every file on your server.

The Nextcloud mobile app has an automatic photo upload feature that works like Google Photos or iCloud Photo Library. Enable it and your phone photos back up to your own server automatically. This single feature is the reason most people in my household stopped caring about which cloud provider they use: they barely notice the difference.

Step 7: Performance Tuning

A default Nextcloud installation will feel sluggish compared to Google Drive or Dropbox. Those companies throw enormous infrastructure at the problem. You have a single server. But there are several things you can do to close the gap significantly.

PHP memory limit

The image’s default PHP memory limit is 512 MB. The compose file above raises it with PHP_MEMORY_LIMIT=1024M and the upload limit with PHP_UPLOAD_LIMIT=10G. Set them there rather than by editing PHP files inside the container: anything you write inside the container is lost the next time it is recreated, which is every update. Change the values and run docker compose up -d to apply.

Enable preview generation

Install the Preview Generator app from the Nextcloud App Store. Then run initial generation and add it to cron:

# Initial generation (can take hours with many files)
docker exec -u www-data nextcloud php occ preview:generate-all

# Add to crontab for ongoing generation
*/10 * * * * docker exec -u www-data nextcloud php occ preview:pre-generate

Without this, Nextcloud generates thumbnails on-the-fly when you browse folders, which makes the web interface feel painfully slow on large photo libraries.

The Maintenance Reality

Here is what the other guides will not tell you. Nextcloud requires ongoing maintenance, and it is not always smooth.

Updates can break things. Major version upgrades (e.g., 27 to 28) sometimes break apps or change behaviour. I run updates on a maintenance evening, never on a Friday, and I always check the release notes first. If an app I rely on has not been updated for the new version, I wait.

The admin warnings page will haunt you. Go to Administration Settings > Overview and you will likely see a list of warnings about missing indices, recommended settings, and suggested configurations. Work through them. They are more than nags, because they affect performance and reliability.

Administration settings, Overview, on a fresh install behind a reverse proxy: Security and setup warnings lists a Forwarded for headers error and several warnings (maintenance window, mimetype migrations, database configuration, HTTP headers) plus information notices
Administration settings, Overview, on a fresh install behind a reverse proxy: Security and setup warnings lists a Forwarded for headers error and several warnings (maintenance window, mimetype migrations, database configuration, HTTP headers) plus information notices.

On this install, behind a reverse proxy, the page opened with an error: Forwarded for headers. Nextcloud does not trust the proxy yet, so every visitor looks like the proxy. Tell it which address the proxy connects from with trusted_proxies, as described in the Nextcloud reverse proxy documentation. The value is the proxy’s IP address as Nextcloud sees it: for a proxy on another machine, that machine’s address (for example 192.0.2.10); for a proxy on the same host as the container, the Docker network gateway, which was 172.18.0.1 in the lab (docker network inspect nextcloud_default shows it). The other warnings that cleared in the lab have one command each:

# the proxy's address as Nextcloud sees it
docker exec -u www-data nextcloud php occ config:system:set trusted_proxies 0 --value=172.18.0.1

# a quiet hour for heavy background jobs (1 = 01:00 UTC)
docker exec -u www-data nextcloud php occ config:system:set maintenance_window_start --type=integer --value=1

# default country for phone numbers without a country code
docker exec -u www-data nextcloud php occ config:system:set default_phone_region --value=GB

# the "mimetype migrations available" warning
docker exec -u www-data nextcloud php occ maintenance:repair --include-expensive

Reload the Overview page and those warnings are gone. What remains is normal for a fresh install: the HSTS header (set it in your reverse proxy once HTTPS works everywhere), some database tuning hints, and information notices about email and two-factor authentication.

The same page after the occ fixes in this guide: the Forwarded for headers error, the maintenance window, mimetype migration and phone region warnings are gone. The HSTS header, the database tuning hints and the information notices remain, which is normal
The same page after the occ fixes in this guide: the Forwarded for headers error, the maintenance window, mimetype migration and phone region warnings are gone. The HSTS header, the database tuning hints and the information notices remain, which is normal.

File locking can misbehave. If a sync client crashes mid-upload, files can get stuck in a locked state. Stale locks expire on their own (after an hour by default). To clear them sooner with Redis locking, put Nextcloud in maintenance mode (docker exec -u www-data nextcloud php occ maintenance:mode --on), flush Redis (docker exec nextcloud-redis redis-cli -a 'your-redis-password' FLUSHALL), then turn maintenance mode --off. Knowing this exists will save you a stressful evening.

Back up before every major update. Not “I should back up,” but actually do it. Run docker exec -u www-data nextcloud php occ maintenance:mode --on, back up the database and data directory, then proceed. I have needed to roll back twice. Both times, having that pre-update backup meant the difference between a minor inconvenience and a weekend of data recovery.

Backup Strategy

You need to back up three things: the database, the data directory, and the config. The Nextcloud admin manual’s backup chapter lists five (config, custom apps, data, theme and database) and says to put the instance in maintenance mode while you copy them. The script below does the database and the config; the data directory is the rsync job after it. Save the script as nextcloud-backup.sh in the same folder as docker-compose.yml and .env, make it executable, and run it with sudo.

#!/bin/bash
# nextcloud-backup.sh: run it with sudo, from the folder that holds docker-compose.yml and .env
set -euo pipefail

APP_DIR="$(cd "$(dirname "$0")" && pwd)"
BACKUP_DIR="${BACKUP_DIR:-/var/backups/nextcloud}"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)

# Load MYSQL_PASSWORD from the stack's .env file
set -a; . "${APP_DIR}/.env"; set +a

umask 077
mkdir -p "${BACKUP_DIR}"

# However the script ends, success or failure, switch maintenance mode off again
trap 'docker exec -u www-data nextcloud php occ maintenance:mode --off' EXIT
docker exec -u www-data nextcloud php occ maintenance:mode --on

# Dump the database
docker exec nextcloud-db mariadb-dump -u nextcloud -p"${MYSQL_PASSWORD}" nextcloud \
  > "${BACKUP_DIR}/db_${TIMESTAMP}.sql"

# Archive the config (owned by www-data, mode 640, which is why this needs sudo)
tar czf "${BACKUP_DIR}/nextcloud_config_${TIMESTAMP}.tar.gz" \
  -C "${APP_DIR}" html/config

echo "[$(date)] Backup completed in ${BACKUP_DIR}"

Three details in that script matter:

  • It needs sudo. html/config/config.php is owned by the web server account inside the container and has mode 640, so an ordinary user cannot read it. Run as a normal user, tar stops with Permission denied.
  • The trap is the safety net. With set -e, the first failing command ends the script. In an earlier version of this guide the switch-off line sat at the bottom, so a failed tar left Nextcloud in maintenance mode and every user saw the maintenance page. The EXIT trap runs whether the script finishes or fails.
  • Backups are readable by root only (umask 077, /var/backups/nextcloud), because the database dump holds every account and share.

This is the failure path in the lab, with BACKUP_DIR pointed at the home folder so the first steps work and the script run as an ordinary user: maintenance mode goes on, tar cannot read config.php, the script stops, and the trap turns maintenance mode off on the way out. The last line confirms it:

The backup script run as an ordinary user (with BACKUP_DIR in the home folder so the first steps work): maintenance mode goes on, tar cannot read config.php, the script stops, and the trap turns maintenance mode off on the way out
The backup script run as an ordinary user (with BACKUP_DIR in the home folder so the first steps work): maintenance mode goes on, tar cannot read config.php, the script stops, and the trap turns maintenance mode off on the way out.

And this is the same script with sudo:

The same script run with sudo: maintenance mode on, database dumped, config archived, maintenance mode off by the trap, and the two backup files listed
The same script run with sudo: maintenance mode on, database dumped, config archived, maintenance mode off by the trap, and the two backup files listed.

Check a backup is usable before you need it: the archive should list config.php and the dump should contain the Nextcloud tables. The folder is readable by root only, so the wildcard has to be expanded by root too, which is why the commands go through sudo sh -c:

sudo sh -c 'tar tzf /var/backups/nextcloud/nextcloud_config_*.tar.gz | head -5'
sudo sh -c "grep -c 'CREATE TABLE' /var/backups/nextcloud/db_*.sql"
Checking the backups are real: the config archive lists config.php, and the database dump holds the Nextcloud tables. The folder is readable by root only, so the glob has to be expanded by root too (sudo sh -c)
Checking the backups are real: the config archive lists config.php, and the database dump holds the Nextcloud tables. The folder is readable by root only, so the glob has to be expanded by root too (sudo sh -c).

To run it nightly, put it in root’s crontab (sudo crontab -e) with the full path to the script, for example 30 2 * * * /path/to/nextcloud/nextcloud-backup.sh. Restoring is a separate exercise this lab did not run: try it on a spare machine before you rely on these files.

For the data directory itself, use rsync rather than tar for incremental backups. A full tar of hundreds of gigabytes of files is impractical for nightly runs.

Where you’ll meet this at work

Companies run the same job as SharePoint and OneDrive in Microsoft 365, which Microsoft describes as cloud-based services that help organisations share and manage content. File sync, sharing links and shared team folders map across. The Security and setup warnings page you worked through has a managed cousin in Microsoft Secure Score, a measure of an organisation’s security posture where a higher number means more of the recommended actions have been taken. The backup script has one too: Microsoft 365 Backup can back up all or selected SharePoint sites, OneDrive accounts and Exchange mailboxes.

What maps one to one: a sync client, a shared folder, a WebDAV endpoint, a list of recommended fixes and a backup that has to be tested. What doesn’t: in Microsoft 365 you do not run the database, the cache, cron, TLS or the upgrades, and this guide builds none of the governance side (retention, compliance search, conditional access), so do not read it as a like-for-like replacement for a managed tenant.

The home version teaches the layers a managed service hides, so when a sync problem lands on your desk you already know where to look: the database, the cache, the background jobs or the proxy.

Troubleshooting

Sync client stuck or showing conflicts

The most common sync issue is file locking. Check the Nextcloud log at Administration Settings > Logging for lock-related errors. If files are genuinely stuck, clear the locks as described in the maintenance section above (maintenance mode on, flush Redis, maintenance mode off). For persistent conflicts, the sync client’s activity panel shows exactly which files are affected and why.

“Access through untrusted domain” error

You are accessing Nextcloud via a domain or IP that is not in the trusted domains list. The server answers with HTTP 400, and trusted_domains holds only localhost and the name from NEXTCLOUD_DOMAIN. This catches everyone who tries to access via IP address after setting up a domain.

The 'Access through untrusted domain' error from the troubleshooting section, reproduced: a request with a Host name that is not in trusted_domains is refused with HTTP 400. The domain that is trusted is in config.php
The ‘Access through untrusted domain’ error from the troubleshooting section, reproduced: a request with a Host name that is not in trusted_domains is refused with HTTP 400. The domain that is trusted is in config.php.

Add the name with occ rather than editing config.php, which belongs to the web server account inside the container. The number is the next free index in the list:

docker exec -u www-data nextcloud php occ config:system:set trusted_domains 2 --value=nc.example.test
docker exec -u www-data nextcloud php occ config:system:get trusted_domains
The untrusted-domain fix: add the name with occ config:system:set trusted_domains (config.php is owned by www-data, so no hand-editing), then the same request is no longer refused
The untrusted-domain fix: add the name with occ config:system:set trusted_domains (config.php is owned by www-data, so no hand-editing), then the same request is no longer refused.

Everyone sees the maintenance page

Maintenance mode is still on, usually because a backup or upgrade script stopped before it switched it off. Check and clear it:

docker exec -u www-data nextcloud php occ maintenance:mode
docker exec -u www-data nextcloud php occ maintenance:mode --off
What every user sees while maintenance mode is on. If this page is still there after a backup has finished, the script died before it switched maintenance mode off: occ maintenance:mode --off brings the site back
What every user sees while maintenance mode is on. If this page is still there after a backup has finished, the script died before it switched maintenance mode off: occ maintenance:mode –off brings the site back.

Slow web interface

If the web UI takes several seconds to load folders, check that Redis is connected (look in the admin overview for memory cache status), ensure the cron job is running (check Administration Settings > Basic settings for the last cron execution time), and run the preview generator. These three things account for 90% of performance complaints.

Backup script says “Permission denied”

tar: html/config/config.php: Cannot open: Permission denied means the script ran as an ordinary user. Run it with sudo, as in the Backup Strategy section.

Upload fails for large files

Check your reverse proxy’s client max body size (see Step 4), the PHP upload limit (PHP_UPLOAD_LIMIT in the compose file, 512 MB by default in the official image), and available disk space. All three must allow the file size you are attempting.

What to Do Next

Nextcloud is a significant step toward owning your data. But a file sync platform on its own is just the beginning. Here is where to go from here:

The maintenance overhead is real, but so is the peace of mind. Your files live on your hardware, backed up on your schedule, accessible on your terms. No storage limits, no scanning, no surprise pricing changes. That is worth a maintenance evening once a month.

Watch out for this: Watch your PHP memory limits. The default Docker config often sets them too low, and you will get cryptic errors during large file uploads. I set mine to 1G and the random upload failures disappeared.

Key Takeaways

  • Always deploy Nextcloud with MariaDB and Redis, never with SQLite for real usage. SQLite cannot handle concurrent access from multiple devices.
  • The MariaDB --transaction-isolation=READ-COMMITTED flag is mandatory. Without it, you will get database lock errors under normal use.
  • Set up system cron for background tasks immediately. The default AJAX method is unreliable and leads to subtle performance issues.
  • Configure your reverse proxy to allow large uploads (client_max_body_size): plain Nginx stops at 1 MB by default.
  • Nextcloud is maintenance-heavy compared to other self-hosted services. Pin the major version, upgrade one major at a time, budget a monthly maintenance window, and always back up before major version upgrades.
  • The automatic photo upload on mobile is the killer feature for household adoption. Set it up for every family member’s phone.
  • Back up the database, config, and data directory separately. Use rsync for incremental data backups rather than full archives.
  • Run the backup script with sudo and keep the trap that switches maintenance mode off, or one failed tar leaves your family looking at the maintenance page.

Related Guides

If you found this useful, these guides continue the journey:

The RTM Essential Stack - Gear I Actually Use

Enjoyed this guide?

New articles on Linux, homelab, cloud, and automation every 2 days. No spam, unsubscribe anytime.

Scroll to Top