Drupal 8 - Error - "The provided host name is not valid for this server"


If you are getting the following error

         The provided host name is not valid for this server

Follow the below steps to resolve it.
  • Goto your settings.php file and add the domain you are currently using for the current site as below
                $settings['trusted_host_patterns'] = [
        '^localhost',
        'xyz.com'
                 ];
  • Here, 'xyz.com' is your current domain. 
  • You can use regrex pattern for accepting list of domains. For example, for accepting domain starts with 'localhost', I have included '^localhost'. This pattern will accept list of domains like 'localhost', 'localhost:8080','localhost.com',etc,.

Kindly Subsribe to Things to know -Mr Ko & Acquia Pantheon Drupal Blog.
To get latest updates and solutions for the errors you facing.