How to sync KeePassium using Synology NAS

Setup

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

  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
  1. Select DS file in the Locations list. (You might need to make it visible first.)
  2. Select your database file

That’s it!

Troubleshooting

Sticky caching in DS Drive

Databases added via the Synology Drive app (not DS File) are not always automatically downloaded. Therefore, if the database was changed on the server, these changes might not be available in KeePassium. However, changes made in KeePassium are successfully uploaded to the server. This seems like a caching issue in Synology Drive v2.1.0.

To avoid this, please use DS File app instead of Synology Drive.

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

firstBytes: 7b226572726f7222]

This error is caused by two Synology bugs:

  • 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.

We have reported both bugs to Synology in August 2020 (tickets #2591926 and #2604475). The company confirmed the issues and committed to fix them in one of their future updates.

In the meanwhile, there are two possible workarounds for this error:

  • Re-add your database to KeePassium (and/or to the AutoFill).
  • 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 general idea is to force DS File to re-login to the server (thus generating a new, likely valid, session_id value)


See also

Last Updated: 2021-09-17