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

Joycey's avatar

php artisan migrate ERROR for sqlite connection

i am working on laravel on my local system for the first time and followed the step by step instructions but I am getting errors at this point.

This is my .env file: DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database/database.sqlite DB_USERNAME=homestead DB_PASSWORD=secret

This is my database.php: 'default' => env('DB_CONNECTION', 'sqlite')),

    'sqlite' => [
        'driver' => 'sqlite',
        'url' => env('DATABASE_URL'),
       'database' => env('DB_DATABASE', database_path('database/database.sqlite')),
        'prefix' => '',
        'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),

I have created my database/database.sqlite file.

I have ran: php artisan make:auth

Now, I am running php artisan migrate and keep getting the error below:

Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations and table_type = 'BASE TABLE')

at C:\wamp64\www\laravel_bum\student_bum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make this exception a 662| // lot more helpful to the developer instead of just the database's errors. 663| catch (Exception $e) {

664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668|

Exception trace:

1 PDOException::("SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. ") C:\wamp64\www\laravel_bum\student_bum\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead", "homestead", "secret", []) C:\wamp64\www\laravel_bum\student_bum\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

Please use the argument -v to see more details. _________________________________________________________--

Can you please assist on how to fix this error?

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

Looks like the app is attempting to connect to MySQL. You may have cached your config; try clearing it:

php artisan config:clear
Joycey's avatar

Wow.

I have been on this for days .... It worked.

Thanks so much tykus.

tykus's avatar

No worries, can you mark the best reply above

Please or to participate in this conversation.