Two Nextcloud With Single Database


We have setup a Replica of our live nextcloud, both works perfect stand alone.

Now we have created a remote user say replica1 in Mysql and grant him access to Nextcloud database on live nextcloud server. Now on replica nexcloud we have defined database information of live cloud with replica user, in config.php.

Then tried to access replica nextcloud, we have accessed login page but when we enter the credentials gets the following error:


Any hint can be useful.
OS: Ubuntu
NC: 25.0.3

I know dedicated databases are recommended for each NC server. This is test environment and need to do it as our specific requirements. So if some give idea then it can be a great help

Afaik this is not only recommended, but mandatory. I’m not an expert, but I can think of all sorts of potential issues and conflicts when using an existing database for a second Nextcloud instance

Then you should certainly not mess around with the production database in any way, and therefore not only use a separate database, but a completely separate database instance on a separate server / VM.

Regarding the error message I found this: [Bug]: NC 24.0.5 hash_hkdf(): Argument #2 ($key) cannot be empty in .../lib/private/Security/Crypto.php:97 · Issue #34012 · nextcloud/server · GitHub Maybe it helps to point you at least in the right direction.

full ack for @bb77

I’m sure application needs write access to DB e.g. to update “last login” timestamp etc…

independent from what you trying to achieve sharing DB is wrong.

  • If you look for “integration/acceptance” environment - perform a clone of your production into separate system and use same config…
  • if you look for disaster recovery - it’s harder but more is possible splitting the taks of “restore” into different actions:
    – replicate the storage “fast enough”
    – have a read-only DB replica running and copy transaction logs to the replica
    – know how you make a DB replica read/write and start the replica Nextcloud “primary” (e.g. DNS)

Sharing database is wrong. Agree to that. However some does not have the luxury of having access to or capacity to run more than one database server. It is perfectly possible to host two seperate databases on same instance. However it comes with some bottlenecks in terms of performance.
Nextcloud does background jobs through cron, aswell as both indexing and previews (if you have installed that). This stresses the database server somewhat. When two Nextcloud instances does this simultanously, each Nextcloud will feel slow and sluggish. Does this mean it cannot be done? No not at all. Make sure your database host has lots of computing power, memory and maximum file descriptors (4000) if running *NIX

Yes. You can use two Nextclouds with only one database server.


Maybe both CRON can differ a bit by using different settings. :wink: I also don’t know if it really produces that much load on the database.

Yes. At some providers e.g. the webspace is not on the same server and you do not get only shared space but also a shared database.

1 Like

Yeah I can see that, and if so I guess it’s ok to add another database on the same instance, if you know what you’re doing. :wink:

But this…

…I don’t know, but to me this is literally screaming “problems and data loss”. Also, I suspect he wants to do it this way because he can’t get the necessary privileges on the database instance for creating a new database… which would make this an even worse idea. :wink:

1 Like


When you use the same database, please use the same config.php. At least the same values for instanceid, passwordsalt and secret.