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.
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.