QGIS asks for PostgreSQL credentials multiple times

The problem seems to have been caused by adding layers at different times. If I add a layer to an existing project I get prompted for credentials for each time layer(s) are added. If I start a fresh project and add all the layers at once I only get one username/password prompt.


I would recommend converting user name and password into a configuration, that is stored behind masterpassword in QGIS. This also means your user name and password are not stored as plain text in QGIS project file. I recommend reading authentication section in QGIS documentation: https://docs.qgis.org/3.16/en/docs/user_manual/auth_system/auth_overview.html One thing to note here: If you are adding data from different machines or opening your QGIS project file from different machines, your configuration ID-s should match. You can change configuration ID by clicking a padlock and unlock it.