Untrusted Host error

Hello,

Got a weird error going on and was seeking some guidance on how to fix or look for the solution because I’m stuck.

Basically, I have a Mautic site running 2.8.1 on a Digital Ocean server maintained by ServerPilot, running Nginx with an Apache proxy.

I’ve ssh’d in and setup my SSL key & certificate and redirected all traffic to HTTPS version.

All that’s working great.

But in the Mautic —> Systems —> Logs area, I have the following error (I removed any identifying info):

Code:
[2017-06-21 15:23:14] mautic.CRITICAL: Uncaught PHP Exception UnexpectedValueException: "Untrusted Host "My.Server.IP.Addy"" at /path/to/mautic/vendor/symfony/http-foundation/Request.php line 1254 {"exception":"[object] (UnexpectedValueException(code: 0): Untrusted Host "My.Server.IP.Addy" at /srv/users/serverpilot/apps/mautic/public/vendor/symfony/http-foundation/Request.php:1254)"} []

Any suggestions on how to fix this?
As I said, it seems to be running HTTPS just fine, get the little lock icon & all.
My certificate issuer is GoDaddy, and I've got a CA bundle by it's not cited for use by Nginx.

Any advice on how to fix this error would be greatly appreciated.

My Nginx config file looks like this:
Code:
server { listen 443 ssl; listen [::]:443 ssl; server_name server-mautic domain.name.com ;
  ssl on;

ssl_certificate /path/to/certs/ssl/certificatefile.crt;
ssl_certificate_key /path/to/certs/ssl/keyfile.key;

root   /path/to/public_html;


access_log  /path/to/log/mautic/mautic_nginx.access.log  main;
error_log  /path/to/log/mautic/mautic_nginx.error.log;

proxy_set_header    Host              $host;
proxy_set_header    X-Real-IP         $remote_addr;
proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
proxy_set_header    X-Forwarded-SSL on;

include /path/to/nginx/vhosts.d/mautic.d/*.nonssl_conf;
include /path/to/nginx/vhosts.d/mautic.d/*.conf;

}

Hello,
Got a weird error going on and was seeking some guidance on how to fix or look for the solution because I’m stuck.
Basically, I have a Mautic site running 2.8.1 on a Digital Ocean server maintained by ServerPilot, running Nginx with an Apache proxy.
I’ve ssh’d in and setup my SSL key & certificate and redirected all traffic to HTTPS version.
All that’s working great.
But in the Mautic —> Systems —> Logs area, I have the following error (I removed any identifying info):

[2017-06-21 15:23:14] mautic.CRITICAL: Uncaught PHP Exception UnexpectedValueException: "Untrusted Host "My.Server.IP.Addy"" at /path/to/mautic/vendor/symfony/http-foundation/Request.php line 1254 {"exception":"[object] (UnexpectedValueException(code: 0): Untrusted Host "My.Server.IP.Addy" at /srv/users/serverpilot/apps/mautic/public/vendor/symfony/http-foundation/Request.php:1254)"} []

Any suggestions on how to fix this?
As I said, it seems to be running HTTPS just fine, get the little lock icon & all.
My certificate issuer is GoDaddy, and I’ve got a CA bundle by it’s not cited for use by Nginx.

Any advice on how to fix this error would be greatly appreciated.

My Nginx config file looks like this:

server {
   listen       443 ssl;
    listen       [::]:443 ssl;
    server_name
        server-mautic
        domain.name.com
      ;

      ssl on;

    ssl_certificate /path/to/certs/ssl/certificatefile.crt;
    ssl_certificate_key /path/to/certs/ssl/keyfile.key;

    root   /path/to/public_html;


    access_log  /path/to/log/mautic/mautic_nginx.access.log  main;
    error_log  /path/to/log/mautic/mautic_nginx.error.log;

    proxy_set_header    Host              $host;
    proxy_set_header    X-Real-IP         $remote_addr;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-SSL on;

    include /path/to/nginx/vhosts.d/mautic.d/*.nonssl_conf;
    include /path/to/nginx/vhosts.d/mautic.d/*.conf;
}

Thanks MxyzptlkFishStix,
Now I just feel stupid, that seems to have fixed the issue.
It’d be nice if Mautic could account for it’s server IP automatically.
Thanks for the advice that solved the problem!

Your software
My Mautic version is: unknown – I’m locked out
My PHP version is: 7.1

Your problem
I added an invalid value to the Trusted Hosts list in my configuration. Saving the change immediately locked me out of my Mautic site.

There is an old (closed) thread on GitHub which is discussing this same problem that I have. There is a somewhat incomplete solution posted, but requests for more detail went unanswered.

GitHub thread: https://github.com/mautic/mautic/issues/4315

These errors are showing in the log:
Line 1: [2020-05-10 03:02:53] mautic.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: “Untrusted Host “mautic.xyz.info”” at /var/www/html/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php line 120 {“exception”:"[object] (Symfony\Component\HttpKernel\Exception\BadRequestHttpException(code: 0): Untrusted Host “mautic.xyz.info” at /var/www/html/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php:120, UnexpectedValueException(code: 0): Untrusted Host “mautic.xyz.info” at /var/www/html/mautic/app/bootstrap.php.cache:950)"}

Steps I have tried to fix the problem:
The suggested solution on Github was:
The solution in this scenario was to edit the local.php file in app/config and then manually clear the cache.

I found the offending line in:
var/www/html/mautic/app/config/local.php

I recognize the incorrect domain I entered by mistake. So I have changed that back to the correct domain.

The second part of the suggested solution is: “…then manually clear the cache.” I renamed the app/cache directory, rather than deleting it.

I tried to reset permissions and got a message saying “cannot access ‘/var/www/html/mautic/’”

I tried to restart Apache and got the message. “Failed to restart apache2.service: Unit apache2.service not found”.

If I access the site with the IP address, I get the Apache2 Ubuntu Default Page, which says:
If you can read this page, it means that the Apache HTTP server installed at this site is working properly.

The error persists, and I’m completely lost. Any help much appreciated.

Solution that worked for me:

(1) Correct the local.php file

Remove the offending line altogether.

In app/config/local.php file

from:

'trusted_hosts' => array( 
'0' => 'http://domain-xyz.com'
 ),

to:

'trusted_hosts' => array(

 ),

(2) Clear the cache

sudo rm -fr app/cache/*

Hi,

I think the cache folder doesn’t get recreated I would say

  • Rename the cache folder back

  • Make a copy of the cache folder to back it up

  • Clear the original folder cache using rm -rf app/cache/*

I was changing the whitelisted domains and CORs settings and must have accidentally put the wrong domain. Now I can’t access the Dashboard anymore because it the log says “Untrusted host”.

How do I fix this without doing a reinstall? I presume I can edit the db somehow.

Found it!

app/config/local.php

Old topic, but is there any chance I can get the detail on exactly how the app/config/local.php should be changed?

Because I have the same problem and I have tried, removing the bad line, commenting it out, and replacing it with the correct domain that Mautic is installed on, and I am still locked out.

Your software
My Mautic version is: unknown – I’m locked out
My PHP version is: 7.1

Your problem
I added an invalid value to the Trusted Hosts list in my configuration. Saving the change immediately locked me out of my Mautic site.

There is an old (closed) thread on GitHub which is discussing this same problem that I have. There is a somewhat incomplete solution posted, but requests for more detail went unanswered.

GitHub thread: https://github.com/mautic/mautic/issues/4315

These errors are showing in the log:
Line 1: [2020-05-10 03:02:53] mautic.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: “Untrusted Host “mautic.xyz.info”” at /var/www/html/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php line 120 {“exception”:"[object] (Symfony\Component\HttpKernel\Exception\BadRequestHttpException(code: 0): Untrusted Host “mautic.xyz.info” at /var/www/html/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php:120, UnexpectedValueException(code: 0): Untrusted Host “mautic.xyz.info” at /var/www/html/mautic/app/bootstrap.php.cache:950)"}

Steps I have tried to fix the problem:
The suggested solution on Github was:
The solution in this scenario was to edit the local.php file in app/config and then manually clear the cache.

I found the offending line in:
var/www/html/mautic/app/config/local.php

I recognize the incorrect domain I entered by mistake. So I have changed that back to the correct domain.

The second part of the suggested solution is: “…then manually clear the cache.” I renamed the app/cache directory, rather than deleting it.

I tried to reset permissions and got a message saying “cannot access ‘/var/www/html/mautic/’”

I tried to restart Apache and got the message. “Failed to restart apache2.service: Unit apache2.service not found”.

If I access the site with the IP address, I get the Apache2 Ubuntu Default Page, which says:
If you can read this page, it means that the Apache HTTP server installed at this site is working properly.

The error persists, and I’m completely lost. Any help much appreciated.

Hi folks,

I’m I have just merged multiple threads on the same topic into this post to reduce duplication and make it easier for people to find information.

BOOM, just got caught by this myself.

Could this be due to including http:// or https:// in the url. Being that this field also accepts REGEX perhaps these chars are confusing the sys?

If that is the case perhaps and entry filter on the field submitted or some kind of error message at form submit?