# Untrusted Host error

**URL:** <https://forum.mautic.org/t/untrusted-host-error/8787>\
**Category:** Product Support\
**Created:** [June 21, 2017, 6:34pm UTC](https://forum.mautic.org/t/untrusted-host-error/8787 "2017-06-21T18:34:58Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huckleberry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/huckleberry/32/535_2.png) [@Huckleberry](https://forum.mautic.org/u/Huckleberry)\
**Post date:** [June 21, 2017, 6:34pm UTC](https://forum.mautic.org/t/untrusted-host-error/8787/1 "2017-06-21T18:34:58Z")

</div>

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;

```

}

---

<div class="post-metadata">

**Author:** ![Huckleberry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/huckleberry/32/535_2.png) [@Huckleberry](https://forum.mautic.org/u/Huckleberry)\
**Post date:** [June 21, 2017, 6:34pm UTC](https://forum.mautic.org/t/untrusted-host-error/8787/2 "2017-06-21T18:34:58Z")

</div>

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):

```auto
[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:

```auto
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;
}

```

---

<div class="post-metadata">

**Author:** ![Huckleberry](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/huckleberry/32/535_2.png) [@Huckleberry](https://forum.mautic.org/u/Huckleberry)\
**Post date:** [June 22, 2017, 7:56pm UTC](https://forum.mautic.org/t/untrusted-host-error/8787/3 "2017-06-22T19:56:24Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![rdh001](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rdh001/32/666_2.png) [@rdh001](https://forum.mautic.org/u/rdh001)\
**Post date:** [May 10, 2020, 7:06am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/5 "2020-05-10T07:06:39Z")

</div>

**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](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.

---

<div class="post-metadata">

**Author:** ![rdh001](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rdh001/32/666_2.png) [@rdh001](https://forum.mautic.org/u/rdh001)\
**Post date:** [May 10, 2020, 4:17pm UTC](https://forum.mautic.org/t/untrusted-host-error/8787/6 "2020-05-10T16:17:18Z")

</div>

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/*`

---

<div class="post-metadata">

**Author:** ![renzof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/renzof/32/1738_2.png) [@renzof](https://forum.mautic.org/u/renzof)\
**Post date:** [May 11, 2020, 7:00am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/7 "2020-05-11T07:00:10Z")

</div>

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/\*

---

<div class="post-metadata">

**Author:** ![skillit](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@skillit](https://forum.mautic.org/u/skillit)\
**Post date:** [May 17, 2018, 12:51am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/8 "2018-05-17T00:51:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![skillit](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@skillit](https://forum.mautic.org/u/skillit)\
**Post date:** [May 17, 2018, 1:01am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/9 "2018-05-17T01:01:08Z")

</div>

Found it!

app/config/local.php

---

<div class="post-metadata">

**Author:** ![rdh001](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rdh001/32/666_2.png) [@rdh001](https://forum.mautic.org/u/rdh001)\
**Post date:** [May 10, 2020, 8:05am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/10 "2020-05-10T08:05:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rdh001](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rdh001/32/666_2.png) [@rdh001](https://forum.mautic.org/u/rdh001)\
**Post date:** [May 10, 2020, 7:06am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/11 "2020-05-10T07:06:39Z")

</div>

**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](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.

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [May 11, 2020, 7:44am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/12 "2020-05-11T07:44:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aglyons](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aglyons/32/2825_2.png) [@aglyons](https://forum.mautic.org/u/aglyons)\
**Post date:** [July 5, 2020, 9:36pm UTC](https://forum.mautic.org/t/untrusted-host-error/8787/13 "2020-07-05T21:36:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![WPJohnny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/wpjohnny/32/13966_2.png) [@WPJohnny](https://forum.mautic.org/u/WPJohnny)\
**Post date:** [April 30, 2025, 9:38am UTC](https://forum.mautic.org/t/untrusted-host-error/8787/14 "2025-04-30T09:38:55Z")

</div>

I got hit by this and corrected it myself. Anybody reading today…updated path is /mautic/config/local.php/
