I have several QGIS documents that pull layers and tables from PostgreSQL / PostGIS databases. When I open the documents QGIS asks for the the credentials several (5-8+) times. Each document pulls its data from a single database, the credentials given have the same level of access to all layers and tables in the database. Is there a way to get the number of requests down to one per session?

  • 1
    you have to save the username as well as the password (if this changes then you will have to login multiple times).
    – Mapperz
    Apr 30, 2019 at 18:25
  • I'm trying to get by without saving the username / password permanently. I just want to be able to only enter it once per session. May 1, 2019 at 13:59

3 Answers 3


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.


In my case, removing the "sslmode=disable" text from each y the .qgs file solved the issue.

Looks like new layers added in my project do not add the sslmode param and old ones (maybe added with QGIS2 some time ago) all have the param in their datasource. This param caused asking for the user/pass two times every time I opened the project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.