Nextcloud says Access through untrusted domain
You installed Nextcloud with Deployrr. When you open it, you get a Nextcloud page about an untrusted domain instead of the login page. This page shows how to add your address to Nextcloud’s list of allowed addresses.
Symptoms
Section titled “Symptoms”You open https://nextcloud.YOUR_DOMAIN, or http://SERVER_IP:PORT. Nextcloud shows this:
Access through untrusted domainPlease contact your administrator. If you are an administrator, edit the "trusted_domains" setting in config/config.phpNextcloud only answers on addresses in its trusted_domains setting. localhost always works. Behind Traefik, Nextcloud checks the address Traefik passes on to it, which is your subdomain.
Deployrr installs Nextcloud for you, with the admin user already set. There is no web setup page. The line NEXTCLOUD_TRUSTED_DOMAINS in nextcloud.yml only counts during that first install. After that, uncommenting it and recreating the container changes nothing. So your subdomain and your server IP may not be in the list.
On an installed Nextcloud, OVERWRITEHOST is the setting in nextcloud.yml that takes effect after a Recreate. Fix 2 below covers it.
If you use Nextcloud without Traefik, at http://SERVER_IP:PORT, read Local installs without Traefik too.
Fix 1: add the addresses with occ (recommended)
Section titled “Fix 1: add the addresses with occ (recommended)”occ is Nextcloud’s command line tool. It changes the setting safely and takes effect at once. You don’t need a restart.
-
See what Nextcloud trusts now:
Terminal window sudo docker exec --user www-data nextcloud php occ config:system:get trusted_domainsIt prints one address per line. The first line is index
0. Count the lines to find the next free index. If you seelocalhostonly, the next index is1. -
Add your subdomain at the next free index. Replace
nextcloud.example.comwith your Nextcloud address, and1with your free index:Terminal window sudo docker exec --user www-data nextcloud php occ config:system:set trusted_domains 1 --value=nextcloud.example.comLeave out
https://and any port. Nextcloud ignores the port when it compares. -
Run the command from step 1 again. Your subdomain should now be in the list.
-
Reload Nextcloud in your browser.
Fix 2: set OVERWRITEHOST
Section titled “Fix 2: set OVERWRITEHOST”This option makes Nextcloud trust every address and build all its links with your subdomain. It turns off Nextcloud’s address check, so Fix 1 is the safer choice when you can use it. Use Fix 2 only if you reach Nextcloud through Traefik with your own domain.
-
Open
YOUR_DOCKER_FOLDER/compose/HOSTNAME/nextcloud.yml. See Docker folder layout for both placeholders. -
In the
environmentsection, remove the#in front ofOVERWRITEHOST:- OVERWRITEHOST=$NEXTCLOUD_SUBDOMAIN.$DOMAINNAME_1 -
You can remove the
#in front ofNEXTCLOUD_TRUSTED_DOMAINStoo. It does no harm, but it only matters on a fresh install. -
Save the file.
-
Recreate Nextcloud. Go to Tools > Stack Manager > Recreate and pick
nextcloud, notnextcloud-mariadbornextcloud-redis. This needs a Basic, Plus or Pro license. See Stack Manager. If you set up the Deployrr bash aliases, you can run this instead:Terminal window dcrec nextcloudWithout Stack Manager or the aliases, run this. Replace
YOUR_DOCKER_FOLDERandHOSTNAMEas in step 1:Terminal window sudo docker compose --profile all -f YOUR_DOCKER_FOLDER/docker-compose-HOSTNAME.yml up -d --force-recreate nextcloudStart or restart doesn’t read the changed file, so it is not enough. See Restart, Recreate or Reinstall an app after a change.
What this changes:
- Nextcloud accepts any address, so the untrusted page goes away.
- Nextcloud’s links and redirects point to your subdomain, even when you start from another address.
- To undo it, put the
#back and recreate Nextcloud. Then check withsudo docker exec --user www-data nextcloud php occ config:system:get overwritehost. If it still prints your subdomain, remove it withsudo docker exec --user www-data nextcloud php occ config:system:delete overwritehost.
Local installs without Traefik
Section titled “Local installs without Traefik”You can install Nextcloud without Traefik and open it at http://SERVER_IP:PORT. The port is 8081 unless you picked another one. Two things get in the way:
- Your server’s IP address is not in
trusted_domains. Add it with Fix 1, with your IP as the value, for example--value=192.168.1.50. Don’t use Fix 2. nextcloud.ymlhas the line- OVERWRITEPROTOCOL=https. It makes Nextcloud build its links withhttps, but the port only speaks plainhttp. After you log in, you can land on anhttps://SERVER_IP:PORTaddress that doesn’t load.
To switch Nextcloud to plain http:
-
Open
YOUR_DOCKER_FOLDER/compose/HOSTNAME/nextcloud.ymland put a#in front of the line:# - OVERWRITEPROTOCOL=https -
Save the file and recreate Nextcloud as in Fix 2, step 5.
-
Check that the setting is gone:
Terminal window sudo docker exec --user www-data nextcloud php occ config:system:get overwriteprotocolIf it still prints
https, remove it:Terminal window sudo docker exec --user www-data nextcloud php occ config:system:delete overwriteprotocol
If you add Traefik later, remove the # again and recreate Nextcloud.
Behind Nginx Proxy Manager
Section titled “Behind Nginx Proxy Manager”If you use Nginx Proxy Manager instead of Traefik, the untrusted page has the same fix. Add the address you typed in NPM’s Domain Names with Fix 1. In the proxy host, use nextcloud as Forward Hostname / IP and 80 as Forward Port.
You also need to tell Nextcloud to trust NPM. The line TRUSTED_PROXIES=192.168.90.0/24 in nextcloud.yml covers Traefik’s network only. NPM and Nextcloud sit on the default Docker network, and Docker picks its addresses. Until you add that network, Nextcloud sees NPM’s address instead of each visitor’s. Its brute force protection can then slow down logins for everyone after a few failed logins.
-
Find the name of the network Nextcloud is on:
Terminal window sudo docker inspect nextcloud --format '{{range $name, $net := .NetworkSettings.Networks}}{{$name}} {{end}}'It prints your Docker folder’s name plus
_default, for exampledocker_defaultwhen your Docker folder is/home/YOUR_USER/docker. -
Get that network’s address range. Replace
docker_defaultwith the name from step 1:Terminal window sudo docker network inspect docker_default --format '{{range .IPAM.Config}}{{.Subnet}} {{end}}'It prints a range such as
172.18.0.0/16. -
Open
YOUR_DOCKER_FOLDER/compose/HOSTNAME/nextcloud.yml. Add the range to theTRUSTED_PROXIESline, after a space. Keep Traefik’s range:- TRUSTED_PROXIES=192.168.90.0/24 172.18.0.0/16Use a space between the ranges, not a comma.
-
Save the file and recreate Nextcloud as in Fix 2, step 5.
-
Check the setting:
Terminal window sudo docker exec --user www-data nextcloud php occ config:system:get trusted_proxiesIt should print both ranges, one per line.
Set it in nextcloud.yml, not with occ config:system:set. The value in nextcloud.yml takes priority over config.php, so an occ change to trusted_proxies has no effect.
If the stack is ever taken down and started again, Docker can give the default network a new range. If Nextcloud stops showing visitors’ addresses, repeat steps 1 to 4. Repeat them after you reinstall Nextcloud too, because a reinstall copies a fresh nextcloud.yml.
Check it worked
Section titled “Check it worked”- Open
https://nextcloud.YOUR_DOMAIN, orhttp://SERVER_IP:PORTon a local install. You should see the Nextcloud login page. - Log in with the admin user from your install. Deployrr showed it at the end of the install.
- Click around a few pages. The address bar should keep the address you opened.
If it still fails
Section titled “If it still fails”- Same page, address looks wrong. The address in the page’s URL must match what you added, letter for letter. Compare it with
NEXTCLOUD_SUBDOMAINandDOMAINNAME_1in your.env. See Edit .env values and secrets. - You open
http://SERVER_IP:PORTand land on anhttpsaddress that doesn’t load. With Traefik, use your subdomain instead. Without Traefik, see Local installs without Traefik. - A different page, such as
404 page not foundorBad Gateway. The problem is in Traefik, not Nextcloud. See One app behind Traefik shows 404, 502 or Gateway Timeout. - A certificate warning on the subdomain. See Traefik can’t get a Let’s Encrypt certificate.

