Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Muthinicharlie's avatar

Laravel 11 Cpanel Mysql connection Bug

Hello, I created a website and I uploaded it to my cpanel account, it is working well but there is this bug which keeps appearing when I am interacting with the website, it can appear on any page:

" the host localhost is not allowed to connect to this maria db server"

But upon refreshing the page the error goes away, I have contacted my web hosting service provider support but unfortunately they have been unable to help, if anyone can assist me I would appreciate, the error is really bugging.

Here is the detailed logs:

#44 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #45 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #46 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1172): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #47 /home6/im/public_html/index.php(17): Illuminate\Foundation\Application->handleRequest(Object(Illuminate\Http\Request)) #48 {main}

[previous exception] [object] (PDOException(code: 1130): SQLSTATE[HY000] [1130] Host 'localhost' is not allowed to connect to this MariaDB server at /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65) [stacktrace] #0 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(65): PDO->__construct('mysql:host=loca....', 'imak...', Object(SensitiveParameterValue), Array) #1 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(44): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=loca....', 'imak...', 'oui...', Array) #2 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=loca....', Array, Array) #3 /home6/im/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(185): Illuminate\Database\Connectors\MySqlConnector->connect(Array) #4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}() #5

0 likes
5 replies
jlrdw's avatar

the host localhost is not allowed to connect to this maria db server

Didn't you get certain credentials for your Mysql on the host.

Muthinicharlie's avatar

@jlrdw Yes I did, I resolved the error, thank you for your response, I used the host's IP address in the configuration instead of the host name.

twhiting9275's avatar

The answer is in the error:

" the host localhost is not allowed to connect to this maria db server"

How to resolve? This is going to depend on a number of things, but usually this is something you want your host to help out with.

  1. Make sure you are using the correct db username and password in your .env file
  2. Double check that localhost is the correct hosts. Many hosting providers have dedicated SQL servers
  3. Double check that localhost is allowed to connect to the database. This is usually allowed by default in cPanel, but sometimes not. You can check allowed hosts in the cPanel database config screen. You may have to add localhost

Protips: NEVER use localhost. Use 127.0.0.1 instead. If using another host, use that host's IP address, not the DNS name.

ALWAYS edit out the username and domain name when posting log files :)

Muthinicharlie's avatar

@twhiting9275 Thank you very much for your response, I resolved the error, I used the host's IP address in the configuration instead of the host name. I will surely keep in mind to always edit log files before posting.

Please or to participate in this conversation.