How to sync KeePassium using Synology NAS

KeePassium supports automatic two-way synchronization with your Synology NAS.

Setup

There are two sync methods available.

  • KeePassium’s in-app WebDAV support is the most reliable option. The app communicates directly with the NAS and would immediately report any sync issues.
  • Sync via Synology apps is easier to configure. However, it is affected by iOS’ restrictions for background apps. If there is a sync problem, KeePassium might not even know about it.

Using WebDAV connection

  1. Enable WebDAV on your Synology NAS
  2. Add WebDAV connection to KeePassium

Using Synology apps

  1. Install Synology DS file app and enter your credentials
  2. Open KeePassium
    • If the app was just installed, tap Add Existing Database
    • If you already have other databases, tap + and choose Open Database
  3. Select DS file in the Locations list. (You might need to make it visible first.)
  4. Select your database file

Troubleshooting

Sticky caching in Synology Drive

Databases added via the Synology Drive app (not DS File) are not always automatically downloaded/uploaded. Therefore, if the database was changed on the server, these changes might not be available in KeePassium. If the database was changed in KeePassium, Synology Drive might not detect the changes and will not upload the file. This appears to be a caching issue in Synology Drive.

We have reported the bug to Synology in August 2020 (ticket #2604475). The company acknowledged the problem:

Upon further inspection, our developer confirmed that on some occasions, when using the iOS Files app to browse files on Drive, it does not show the latest version of the files.

They are currently working on a fix that will be released on a later date.

As a solution, use DS File or direct WebDAV connection instead.

DS File does not work offline

DS File app requires a working network connection to the server. If the NAS is not available, KeePassium will cancel the connection attempt after several seconds.

If you need access to your database even when the NAS is not available, the best solution is to avoid DS File altogether. Instead, enable WebDAV protocol on your Synology NAS and sync KeePassium via WebDAV.

Unrecognized database format

Sometimes KeePassium fails to load a database from Synology NAS, with the following error in the log:

Unrecognized database format [firstBytes: 7b226572726f7222]

This error is caused by two Synology bugs (reported under ticket #2591926):

  • When DS File connects to the NAS, the mobile app is given a random session_id value. With about 1% probability, this parameter starts with a digit. Since the app does not properly escape the value in further requests, the server is unable to parse the session_id and responds with error code 119.
  • Error code 119 is not documented in Synology API documentation. Apparently, DS File app fails to handle it properly — and considers the error message to be the actual file contents. In other words, KeePassium receives the database as {"error":{"code":119},"success":false} — which is obviously not a valid KeePass database.

There are three possible workarounds for this error:

  • Re-add your database to KeePassium (and/or to the AutoFill). The idea is to force DS File to re-login to the server (thus generating a new, likely valid, session_id value).
  • Turn off the Wi-Fi connection on your device, wait for a minute, then turn it on back again. The NAS should become available again. (The rationale is the same as above.)
  • Use a direct WebDAV connection to your NAS.

See also

Last Updated: 2022-10-04