0

I have the following code where I'm trying to test a connection to postgres:

require 'pg' conn = PGconn.connect("localhost", 5432, '', '', "puppetdb", "puppetdb", "puppetbdb") res = conn.exec('select tablename, tableowner from pg_tables') 

I get back the error:

test.rb:3:in initialize': FATAL: password authentication failed for user "puppetdb" (PG::ConnectionBad) from test.rb:3:innew' from test.rb:3:in `'

Yet I have a python script with the same credentials that seems to work perfectly:

import psycopg2 try: conn = psycopg2.connect("dbname='puppetdb' user='puppetdb' host='localhost' port='5432' password='puppetdb'") 

Given the python script I'm wondering if I've entered the credential wrong?

2
  • localhost and 172.17.0.1 are not the same Commented May 8, 2017 at 12:44
  • Yes @C-Otto I'm updating the python script to read localhost. I just tested locally and the python script works with both URLs. As Docker network is being shared to my localhost. Commented May 8, 2017 at 12:46

1 Answer 1

2

You have a typo in your password (puppetbdb):

conn = PGconn.connect("localhost", 5432, '', '', "puppetdb", "puppetdb", "puppetdb") 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.