QGIS doesn't recognize a GeoPackage ("invalid source"), DB Manager connects to the .gpkg but doesn't find the file ("file not found") when trying to open.

The software DB Browser for SQLite said:

Can't open the database file. Database disk image is malformed.

The project QGIS was closed regularly after saving everything.

How do I repair the corrupted .gpkg?

  • Maybe this helps stackoverflow.com/questions/18259692/…. Possible reasons for corruption sqlite.org/howtocorrupt.html
    – user30184
    Commented Mar 28, 2022 at 10:17
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Commented Mar 28, 2022 at 10:19

1 Answer 1


A geopackage file (.gpkg) is stored as a SQLite3 database. What I found is that when you read/copy a geopackage when it's already in use (for example by connecting to it in QGIS) the database will be locked (read-only).

You'll experience the Can't open the database file. Database disk image is malformed error whenever you try to open a locked gpkg file.

In my case, the solution was to make sure the .gpkg wasn't in use anywhere else before reading/copying.

If you need to unlock a gpkg (sqlite3 database) - check out this SO thread: https://stackoverflow.com/q/151026/2550702

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.