I face the following error in trying to connect to PostgreSql database in (linux) docker container from windows desktop via vbscript:

Microsoft OLE DB Provider for ODBC Drivers (30, 11) : FATAL: password authentication failed for user "dev" FATAL: password authentication failed for user "dev"

Here is the demo vb-code:

Dim cn
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
  'Open the Postgre Databse connection (Driver must be installed)
  cn.Open "Driver={PostgreSQL ANSI};" & _
          "Server=localhost;" & _
          "Port=5432;" & _
          "UID=dev;" & _
          "PWD=dev;" & _
  rs.Open "SELECT * FROM tablename", cn

  While Not rs.EOF
    WScript.Echo( rs("id") & ": " & rs("name"))

And here is the docker-compose.yml:

version: "3.8"

    image: postgres:9.6.3
      POSTGRES_USER: dev
      POSTGRES_DB: dbname
    - 5432:5432
      - anon-pgdata:/var/lib/postgresql/data
    container_name: anon-db

Vbscript above works fine with the non-containerized PostgreSQL database. Can anyone figure out but what is wrong with the container-settings or with something else with the code? The given error speaks of the password / authentication issue but I cannot see why.


I found solution by myself - and the cause of the issue was: if containerized (i.e. host-exposed) postgre-server was running simultaneously with the non-containerized postgre-server the connection did not work.

After shutting down the non-containerized postgre-server, the connection to containerized postgre-server took place normally.

There was a hint to this in the last comment in the following link: https://social.msdn.microsoft.com/Forums/windows/es-ES/6a2fda0a-69b1-4503-8aee-a223e4e9a9d2/fatal-password-authentication-failed-for-user?forum=netfxes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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