Jan 03, 2020 in Drupal 8, Snippets

When installing drupal 8, or moving to production one could see this error. The fix is extremely simple. 

This was a setting that was added to drupal 8 as a security measure. Long story short, this is an extra protection against http host header attacks.

Look for the $settings['trugsted_host_pattersn'] array in your settings file and uncomment if necessary. Next, add (all) your domains to the array. For example:

$settings['trusted_host_patterns'] = array(
  '^.+\.stefvanlooveren\.me$', // also add subdomains like www.st...

Save this, and your error will disappear. Moreover, your site is much more secure now!

More info about Trusted Host settings