My site stopped suddenly, with an error message

The provided host name is not valid for this server.

And even though I removed


Completely from the settings file and cleared the cache via Drush

drush cache-rebuild

also, i tried use this settings:

$settings['trusted_host_patterns'] = [ '.*' ]; and $settings['trusted_host_patterns'] = [];

but, the site still shows the same error, and i cant access Drupal log or anywhere to detected the problem cause.

Apache settings are also fine, like mentioned in one of the previous experiments here

What are the causes of this error and how can it be fixed?


  1. The site was previously working with trusted_host_patterns settings.

  2. my domain name has dash (-), so i used this pattern:

    $settings['trusted_host_patterns'] = ['^[domain/-/name]\.com$', '^www\.[domain/-/name]\.com$', '^www\.[domain\-name]\.com$', '[domain\-name]\.com$', ];

two week ago, but it stopped working suddenly today, and I removed trusted_host_patterns setting, but it not resolved.

Note: I checked adding $settings['trusted_host_patterns'] = [ '.*' ]; and $settings['trusted_host_patterns'] = []; either, both don't work.

  • 1
    All this is fully explained in What does "The provided host name is not valid for this server" mean?. Read the answer!
    – Hudri
    Sep 27, 2021 at 7:59
  • I read this, and I removed $settings['trusted_host_patterns'] Completely because it did not work.
    – Dr.attar
    Sep 27, 2021 at 9:16
  • Deleting a configuration value doesn't magically set a correct value out of the blue. For testing you need at least something like $settings['trusted_host_patterns'] = [ '.*' ]; - FOR TESTING ONLY, don't do this in production. Use your real hostname in production
    – Hudri
    Sep 27, 2021 at 9:27
  • @Hudri i checked adding $settings['trusted_host_patterns'] = [ '.*' ]; and $settings['trusted_host_patterns'] = []; either, both don't work.
    – Dr.attar
    Sep 27, 2021 at 10:04

1 Answer 1


i resolved the problem by:

  1. in centos:

<VirtualHost [domain_name]:80>
ServerName www.[domain_name]
ServerAlias [domain_name]

and, since my domain name has dash, i used this regex:


Not the answer you're looking for? Browse other questions tagged or ask your own question.