Database (database/database.sqlite) does not exist. Database works from artisan tinker
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Database management is an essential part of web application development and Laravel offers a flexible way to handle databases through the database.sqlite file. However, while testing your application, you may face the error 'QueryException in Connection.php line 647: Database (database/database.sqlite) does not exist.' You might wonder why this happens even though the database works from artisan tinker. This blog post will discuss the possible reasons for this issue and provide a working solution.
There could be several factors contributing to this error, including incorrect configuration in the .env file, an issue with the application's code or routing, or a misconfigured database connection in Laravel. Let us dive into each possibility one by one:
1) Incorrect .env File Configuration: Ensure that your .env file is properly configured with the correct values for database-related variables such as DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, etc. It's crucial to note that the absolute path to the database.sqlite file in the DB_DATABASE variable should be accurate and up to date, as incorrect paths can also lead to the mentioned issues. 2) Improper Code or Routing: Check your code, particularly in the DatabaseController class or any other part of your application that interacts with the database. Ensure that you are using the correct database connection name (e.g., 'sqlite'), and querying the appropriate tables from the database. 3) Misconfigured Database Connection: Review your application's database configuration in the config/database.php file, which contains the default Laravel connections and their configurations. Ensure that the sqlite connection is properly set up with its relevant attributes such as 'driver', 'database', and 'prefix'. 4) Temporary Fix via altering database.php: As a temporary fix, you can try changing the database configuration in your config/database.php file from env('DB_DATABASE', database_path('database.sqlite')) to use the absolute path as defined in your .env file (e.g., 'absolute\path\to\database\database.sqlite').While these methods may lead to a working solution, it's crucial to remember that modifying configuration files can cause conflicts and is not recommended for permanent fixes. It would be better to identify the root cause of the issue and address it appropriately.
To conclude, when you face the error 'QueryException in Connection.php line 647: Database (database/database.sqlite) does not exist', you need to carefully analyze your code, configuration files, and routing setup to troubleshoot the actual cause of the problem. Once resolved, ensure that all configurations are up-to-date and properly set to avoid such issues in the future.