Laravel says the SQLite database file does not exist
SQLiteDatabaseDoesNotExistExceptionShort answer
Laravel checks the SQLite file before it connects, and it throws SQLiteDatabaseDoesNotExistException when it cannot resolve the path in DB_DATABASE. The file was never created, the path is wrong or relative, or a DB_URL value overrides the path you edited. Create the file and set an absolute path.
Fix it fast
1Find out which cause you have
Print the connection Laravel actually uses and the path it resolved. This shows whether the file name comes from your .env or from somewhere else.
grep -E '^DB_' .env ls -l database/2Match what you see, then jump to its fix
- 1
The exception names the configured path, and nothing exists thereThe SQLite file was never createdFix - 2
The configured value is a bare word such as laravel, or a relative pathDB_DATABASE holds a name or a path that does not resolveFix - 3
You changed DB_DATABASE and the exception still names an old pathA database URL overrides the path you editedFix
- 1
What does the error look like?
SQLiteDatabaseDoesNotExistException
Cause 1 of 3
The SQLite file was never created
1Check
SQLite keeps the whole database in one file, and Laravel does not make it for you when you point at a new path. List the folder to see if the file is there.
ls -l database/2Fix
Create an empty file at the path, then run your migrations.
touch database/database.sqlite
php artisan migrate3Verify
The file now exists and the connection opens.
php artisan db:showConfirmed by laravel.com
Cause 2 of 3
DB_DATABASE holds a name or a path that does not resolve
1Check
Laravel tries the value as given and then relative to the application base folder. A leftover MySQL-style database name does not match any file, so the lookup fails. Check what .env sets.
grep -E '^DB_' .env2Fix
Set the connection to sqlite and put the absolute path to the file in DB_DATABASE.
DB_CONNECTION=sqlite
DB_DATABASE=/var/www/my-app/database/database.sqlite3Verify
Run a command that opens the connection.
php artisan db:showConfirmed by raw.githubusercontent.com
Cause 3 of 3
A database URL overrides the path you edited
1Check
When the url option (the DB_URL variable) is set, Laravel takes the connection details from it instead of the separate values.
grep -E '^DB_URL' .env2Fix
Remove DB_URL, or change it to point at the same SQLite file.
# .env: delete the DB_URL line, then keep
DB_CONNECTION=sqlite
DB_DATABASE=/var/www/my-app/database/database.sqlite3Verify
Open the connection and read the database overview.
php artisan db:showConfirmed by laravel.com
How do I stop it coming back?
- Keep one absolute DB_DATABASE value per environment in the deploy settings.
- Create the SQLite file in your setup script, before the first migrate.
- Do not leave a DB_URL in .env unless you mean it to win.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
- EZ EstimaterConstruction quoting and job tracking for contractors, on a Laravel and Firebase stack.
- DCORAn offline-first field app with three roles, GPS attendance, a dynamic form engine and five languages.
Related fixes
Back end
PHPUnit in Laravel fails with could not find driver on PRAGMA foreign_keys
could not find driver (SQL: PRAGMA foreign_keys = ON;)
The PRAGMA query is only the first thing Laravel sends to a SQLite connection.
3 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fix