0

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;" & _
          "Database=dbname;"
                    
  rs.Open "SELECT * FROM tablename", cn

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

And here is the docker-compose.yml:

version: "3.8"

services:
  anon-db:
    image: postgres:9.6.3
    environment:
      POSTGRES_USER: dev
      POSTGRES_PASSWORD: dev
      POSTGRES_DB: dbname
    ports:
    - 5432:5432
    volumes:
      - 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.

M.Y.
  • 111
  • 1

1 Answers1

0

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

M.Y.
  • 111
  • 1