Try changing:
DB_CONNECTION=mariadb
to
DB_CONNECTION=mysql
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I have successfully deployed my first Laravel project on a VPS. Everything seems to be working fine—I can store and display data without any issues. However, when I check the log file, I see the following error:
[previous exception] [object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at /home/firstproject/demo/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:66)
[stacktrace]
This issue appears in the laravel.log file.
Also The following error is repeatedly appearing in the worker.log file.
In Connection.php line 825:
SQLSTATE[HY000] [2002] Connection refused (Connection: mariadb, SQL: select
* from `cache` where `key` in (illuminate:queue:restart))
In Connector.php line 66:
SQLSTATE[HY000] [2002] Connection refused
my .env file:
DB_CONNECTION=mariadb
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=secret
DB_USERNAME=secret
DB_PASSWORD=secret
Does anyone know what might be causing this issue?
The issue has been resolved. I added this line into ENV file, and no more errors are being logged.
DB_SOCKET=/var/lib/mysql/mysql.sock
Please or to participate in this conversation.