What the message looks like
Access through untrusted domain. Please contact your administrator. If you are an administrator, edit the "trusted_domains" setting in config/config.php.Common causes
- A new hostname after a domain change or migration that was never added.
- Access directly via the IP address or an internal name.
- The reverse proxy forwards a different
Hostheader than the public name. - Docker:
NEXTCLOUD_TRUSTED_DOMAINSis only applied on the first install.
Check
- Show configured trusted domains
sudo -u www-data php /var/www/nextcloud/occ config:system:get trusted_domains - Check proxy-related settings
grep -nE 'trusted_proxies|overwritehost|overwriteprotocol|overwrite.cli.url' /var/www/nextcloud/config/config.php - Test the backend directly with a Host header
curl -s -o /dev/null -w '%{http_code}\n' -H 'Host: cloud.example.com' http://127.0.0.1/status.php - Check which Host header nginx forwards
nginx -T 2>/dev/null | grep -n 'proxy_set_header Host'
Fix
- Add the domain (use the next free index):
sudo -u www-data php occ config:system:set trusted_domains 1 --value=cloud.example.com. - Forward the original host in the reverse proxy:
proxy_set_header Host $host;. - Behind a proxy set
trusted_proxiesand, if needed,overwritehostandoverwriteprotocol. - With Docker, change the values in
config.phpor via occ inside the container, not just the environment variable.
Typical scenario
The company moves Nextcloud from cloud.old-example.com to cloud.example.com. DNS points to the server, yet 'Access through untrusted domain' appears, including in the desktop clients. config.php only lists the old name. First run occ config:system:get trusted_domains to see which entries are loaded, and compare them with the Host header your reverse proxy passes on to Nextcloud.
FAQ
Can I allow every domain with *?
Wildcards like *.example.com work, a bare * makes no sense. The list protects against host header attacks such as manipulated password reset links.
Do I need to restart anything after the change?
No. Nextcloud reads config.php on every request, so the change applies immediately.
What is trusted_domains for?
The list protects against Host header attacks. If Nextcloud accepted any host, links in mails such as password resets could point to a domain the attacker chose. That is why the check also applies to clients and WebDAV.
Why does the message persist although the name is listed?
Often the proxy forwards a different host, for example the internal name or an address with a port. The entry has to match the incoming host exactly. Set proxy_set_header Host $host in the proxy or list the variant that actually arrives.
Is adding the server's IP address as well enough?
It helps for access by IP, such as locally or inside a Docker network, but is no lasting answer for public access. Certificates match names, not IPs. Keep the list to the names users really use.