{"record":{"id":"f9c126925e867797","repo":"laravel/framework","slug":"database-file-at-path-path-does-not-exist-en","errorCode":null,"errorMessage":"Database file at path [{$path}] does not exist. Ensure this is an absolute path to the database.","messagePattern":"Database file at path \\[(.+?)\\] does not exist\\. Ensure this is an absolute path to the database\\.","errorType":"exception","errorClass":"SQLiteDatabaseDoesNotExistException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Connectors/SQLiteConnector.php","lineNumber":61,"sourceCode":"\n        // SQLite supports \"in-memory\" databases that only last as long as the owning\n        // connection does. These are useful for tests or for short lifetime store\n        // querying. In-memory databases shall be anonymous (:memory:) or named.\n        if ($path === ':memory:' ||\n            str_contains($path, '?mode=memory') ||\n            str_contains($path, '&mode=memory') ||\n            str_starts_with($path, 'file:')\n        ) {\n            return $path;\n        }\n\n        $path = realpath($path) ?: (function_exists('base_path') ? realpath(base_path($path)) : false);\n\n        // Here we'll verify that the SQLite database exists before going any further\n        // as the developer probably wants to know if the database exists and this\n        // SQLite driver will not throw any exception if it does not by default.\n        if ($path === false) {\n            throw new SQLiteDatabaseDoesNotExistException($database);\n        }\n\n        return $path;\n    }\n\n    /**\n     * Set miscellaneous user-configured pragmas.\n     *\n     * @param  \\PDO  $connection\n     * @param  array  $config\n     * @return void\n     */\n    protected function configurePragmas($connection, array $config): void\n    {\n        if (! isset($config['pragmas'])) {\n            return;\n        }\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Database/Connectors/SQLiteConnector.php#L43-L79","documentation":"Thrown as SQLiteDatabaseDoesNotExistException by SQLiteConnector::parseDatabasePath() when realpath() cannot resolve the configured path (and base_path() relative resolution also fails). Laravel refuses to silently create an arbitrary SQLite file at connection time, so it surfaces the missing path explicitly. In-memory databases (:memory:, ?mode=memory, &mode=memory) and file: URIs are exempt.","triggerScenarios":"Configuring a sqlite connection whose 'database' path does not exist on disk and is not an in-memory/URI form. Fires the first time the connection is opened (DB::connection, a migration, a model query).","commonSituations":"First run before migrations create database/database.sqlite; relative path that does not resolve from the working directory; deployed app where the database file was not included/created; typo in DB_DATABASE; running tests without first touching the test sqlite file.","solutions":["Create the file before connecting: touch database/database.sqlite (or run php artisan migrate which will offer to create it).","Set the path correctly in .env: DB_DATABASE=/absolute/path/to/database.sqlite.","Use :memory: for ephemeral/test databases.","Ensure the directory exists and is writable so the file can be created by migrations."],"exampleFix":"// before\n// .env: DB_DATABASE=nonexistent.sqlite\n\n// after\ntouch database/database.sqlite\n// .env: DB_DATABASE=/var/www/html/database/database.sqlite","handlingStrategy":"validation","validationCode":"if ($config['driver'] === 'sqlite'\n    && ! in_array($config['database'], [':memory:'], true)\n    && ! str_starts_with($config['database'], 'file:')\n    && ! str_contains($config['database'], 'mode=memory')\n    && ! file_exists($config['database'])) {\n    throw new \\Illuminate\\Database\\SQLiteDatabaseDoesNotExistException($config['database']);\n}","typeGuard":"function sqliteDatabaseExists(string $path): bool {\n    return $path === ':memory:'\n        || str_starts_with($path, 'file:')\n        || str_contains($path, 'mode=memory')\n        || file_exists($path);\n}","tryCatchPattern":"try {\n    DB::connection()->getPdo();\n} catch (\\Illuminate\\Database\\SQLiteDatabaseDoesNotExistException $e) {\n    touch(database_path('database.sqlite'));\n    DB::reconnect();\n}","preventionTips":["Pre-create the SQLite file in deployment scripts (touch database/database.sqlite).","Use absolute paths for DB_DATABASE in production.","For tests, use :memory: to avoid filesystem dependencies."],"tags":["database","sqlite","filesystem","configuration","laravel"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}