{"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/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Connectors/SQLiteConnector.php#L43-L79","documentation":"Thrown as Illuminate\\Database\\SQLiteDatabaseDoesNotExistException by SQLiteConnector::parseDatabasePath() when the SQLite file path cannot be resolved via realpath()/base_path(). Unlike most drivers, SQLite happily opens a non-existent file, so Laravel pre-checks and refuses to silently create the wrong database.","triggerScenarios":"Configuring a sqlite connection with a 'database' path that does not exist on disk and is not :memory: / a file: URI / a mode=memory DSN. Triggered on first connect (ConnectionFactory -> SQLiteConnector -> parseDatabasePath).","commonSituations":"Wrong/relative path in DB_DATABASE; the database file was deleted or never created; deploying to a fresh environment where database/database.sqlite wasn't shipped; typo'd path; running migrations before the SQLite file exists.","solutions":["Create the database file first: touch database/database.sqlite, or run php artisan migrate with --force / answer 'yes' to the create prompt.","Use an absolute path in DB_DATABASE (e.g. /var/www/app/database/database.sqlite).","For tests or ephemeral runs, use DB_DATABASE=:memory:.","Verify the path with is_file($path) at boot and create it if missing."],"exampleFix":"// before (.env)\nDB_DATABASE=database.sqlite  // relative; realpath() fails\n\n// after\nDB_DATABASE=/var/www/app/database/database.sqlite\n// or create it:\n// touch database/database.sqlite","handlingStrategy":"validation","validationCode":"if (($driver ?? null) === 'sqlite' && $path !== ':memory:' && ! str_starts_with($path, 'file:') && ! is_file($path)) {\n    touch(dirname($path) ?: throw new \\RuntimeException('Missing dir')) && touch($path);\n}","typeGuard":"function sqlitePathExistsOrInMemory(string $path): bool {\n    return $path === ':memory:'\n        || str_contains($path, '?mode=memory')\n        || str_contains($path, '&mode=memory')\n        || str_starts_with($path, 'file:')\n        || is_file($path);\n}","tryCatchPattern":"try {\n    DB::connection()->getPdo();\n} catch (\\Illuminate\\Database\\SQLiteDatabaseDoesNotExistException $e) {\n    @touch($e->path);\n    DB::purge();\n    DB::connection()->getPdo();\n}","preventionTips":["Use absolute paths for DB_DATABASE with sqlite.","Create the file in your deploy/CI script before migrating.","Use :memory: for ephemeral/test runs.","Ship an empty database.sqlite in the repo if appropriate."],"tags":["sqlite","filesystem","configuration"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}