Error establishing a database connection in wordpress

I had this issue some days ago with a multisite, loading a live dump to local development. After some debugging I noticed, that the error message wasn’t right.
The database was connected, but the path in the database to the sites was wrong.
You can check table <your-prefix>_site and <your-prefix>_blogs if columns domain and path are correct.
That solved my problem, as the error message told something else.

error code: 523