0

I can connect to my database just fine by entering psql -U <db_user> -W -h localhost -p <db_port> -d <db_name>. However, when I set up that same connection in a Cubejs backend, queries like http://localhost:4000/cubejs-api/v1/load?query=... return {"error": "Error: password authentication failed for user \"<db_user>\""}.

  1. The database is actually connected via SSH tunnel. I've connected a truly local db to Cubejs before, so I suspect this might be causing trouble.
  2. I attempt the connection like so

new PostgresDriver({
    database: "<db_name>",
    host: "localhost",
    user: "<db_user>",
    password: "<db_password>"
})
3. The logs from the Postgres database only show stuff that looks unrelated to my connection attempts:

2020-11-18 23:42:25 UTC::@:[6677]:LOG: checkpoint starting: time

2020-11-18 23:42:25 UTC::@:[6677]:LOG: checkpoint complete: wrote 1 buffers (0.0%); 0 WAL file(s) added, 0 removed, 1 recycled; write=0.101 s, sync=0.001 s, total=0.115 s; sync files=1, longest=0.001 s, average=0.001 s; distance=65536 kB, estimate=65623 kB

Bananin
  • 69
  • 8
  • 1
    What is the error message from the database server's log file? – jjanes Nov 18 '20 at 22:25
  • You mean the Postgres database, or Cubejs? Where does Cubejs place these logs? – Bananin Nov 18 '20 at 22:31
  • The PostgreSQL database logs. – jjanes Nov 18 '20 at 22:32
  • Just a bunch like these (looks like nothing gets there): 2020-11-18 23:42:25 UTC::@:[6677]:LOG: checkpoint starting: time 2020-11-18 23:42:25 UTC::@:[6677]:LOG: checkpoint complete: wrote 1 buffers (0.0%); 0 WAL file(s) added, 0 removed, 1 recycled; write=0.101 s, sync=0.001 s, total=0.115 s; sync files=1, longest=0.001 s, average=0.001 s; distance=65536 kB, estimate=65623 kB – Bananin Nov 18 '20 at 23:47
  • I'll edit that into the question for better formatting – Bananin Nov 19 '20 at 00:46
  • 2
    There should at least be a message with "password authentication failed", but possibly with extra useful details. Are you sure you are trying to connect to the right database instance? Maybe you have have the wrong port, or the wrong host entirely. (I notice you specify a port with psql, but not with node) – jjanes Nov 19 '20 at 00:54
  • THAT WAS IT! I wasn't providing a port, so it was probably defaulting to `5432`, which is why my previous connections were working. Nice keen eye :D – Bananin Nov 19 '20 at 02:38

0 Answers0