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

lara-user's avatar

[PDOException] SQLSTATE[HY000] [2002] Connection refused

Hello, Install Laravel, database: sqlite.

config/database.php 'default' => env('DB_CONNECTION', 'sqlite'), 'sqlite' => [ 'driver' => 'sqlite', 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', ],


database-> new file database.sqlite

terminal: php artisan migrate Comunicat: [PDOException] SQLSTATE[HY000] [2002] Connection refused

0 likes
3 replies
ShaunL's avatar

Validate that your .env file is not overwriting your default in config/database.php

also would be easier to use mark down to format your code for readability in the future. If you are not familiar please use the 'Use Markdown with GitHub-flavored code blocks.' link below to learn how :)

shahbaazhussain's avatar

Edit your .env file:

DB_CONNECTION=sqlite

and

config/database.php file:

replace

'database' => env('DB_DATABASE', database_path('database.sqlite')),

with

'database' => database_path('database.sqlite'),

It worked for me.

noby's avatar

I have the same problem. I tried the solutions by others(shahbaazhussain), but still not working. Have I forgotten anything else?

Please or to participate in this conversation.