Score:-2

What are the causes of the malfunction (The provided host name is not valid for this server) and how to fix it?

cn flag

My site stopped suddenly, with an error message

The provided host name is not valid for this server.

And even though I removed

$settings['trusted_host_patterns']

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?

note:

  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.

ru flag
All this is fully explained in [What does "The provided host name is not valid for this server" mean?](https://drupal.stackexchange.com/questions/145286/what-does-the-provided-host-name-is-not-valid-for-this-server-mean). Read the answer!
cn flag
I read this, and I removed `$settings['trusted_host_patterns']` Completely because it did not work.
ru flag
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**
cn flag
@Hudri i checked adding `$settings['trusted_host_patterns'] = [ '.*' ];` and `$settings['trusted_host_patterns'] = [];` either, both don't work.
Score:-2
cn flag

i resolved the problem by:

  1. in centos:

/etc/httpd/sites-available/[domain_name].conf
<VirtualHost [domain_name]:80>
ServerName www.[domain_name]
ServerAlias [domain_name]

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

[._:-]

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.