Untrusted Host "localhost" in
This problem occurred for me when building an 8.0.0-beta6 test site on my Ubuntu 14.04 laptop.  I have an Apache web server running locally, with the test site defined using a VirtualHost directive.  I add the domain name of the test site ("example.com") to my /etc/hosts file, pointing to 127.0.2.1, to bypass the need to use real DNS entries.

After installing the site, everything looked fine.  However, I noticed a warning message on the Status Report page about not having trusted_host_patterns set, so I went into my /sites/default/settings.php file and added these lines:

$settings['trusted_host_patterns'] = array(
  '^example\.com$',
  '^www\.example\.com$',
);


Upon saving the file and reloading my browser, I got a very generic error page and, after commenting-out the new lines, noticed the Untrusted Host "localhost"... log message.

It appears that because I'm web-browsing from the same computer on which the web server is running, the Host is at some point getting converted to localhost, and thus is failing to match the set of patterns I had specified.  I was able to fix this issue by changing these lines to:

$settings['trusted_host_patterns'] = array(
  '^example\.com$',
  '^www\.example\.com$',
  '^localhost$',
);


On a site that is intended to be put into production, you might want to utilize a settings.local.php file to specify ^localhost$ as a valid host pattern for testing purposes only.  Note that if you want to do this, you'll need to uncomment these lines in the default settings.php, and move them to the bottom of the settings.php file:

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}


In this case, the settings.php file would only contain the actual domain names:

$settings['trusted_host_patterns'] = array(
  '^example\.com$',
  '^www\.example\.com$',
);


and settings.local.php would contain:

&lt;?php
$settings['trusted_host_patterns'][] = '^localhost$';


to append localhost to the list of valid hosts.  With this configuration, you would not copy the settings.local.php file when copying the site to the production server.