Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check-db.js script should report the actual cause of a connection error #2837

Open
dpk opened this issue Jul 6, 2024 · 3 comments
Open

check-db.js script should report the actual cause of a connection error #2837

dpk opened this issue Jul 6, 2024 · 3 comments

Comments

@dpk
Copy link

dpk commented Jul 6, 2024

Describe the feature or enhancement

While trying to install Umami I was stuck for quite a while at this stage:

✓ DATABASE_URL is defined.
✗ Unable to connect to the database.

The check-db.js script does not report what the actual exception raised by Prisma was. Credentials were correct, I was able to do a manual connection with psql with the given password etc., but this error persisted.

The problem turned out to be that Prisma was not finding the right version of the OpenSSL library*. But finding this out involved quite a bit of guesswork and wasted over an hour of my life.

The check-db.js script should actually show the exception that caused the connection to fail.

(* Why on earth it needs this in order to connect to a local database without SSL is anyone’s guess …)

@mikecao
Copy link
Collaborator

mikecao commented Jul 8, 2024

It should report it now in the latest version.

@dpk
Copy link
Author

dpk commented Jul 8, 2024

?

async function checkConnection() {
try {
await prisma.$connect();
success('Database connection successful.');
} catch (e) {
throw new Error('Unable to connect to the database.');
}
}

This is the version of the script I was using, the latest commit, and it does not report the actual cause of the problem.

@boly38
Copy link

boly38 commented Jul 11, 2024

Hi, I'm using provided docker compose and I'm having this issue too.

I would suggest getting more details about this error too (if possible).
NB: if needed umami could add an optional ENV variable to switch at DEBUG or VERBOSE level if it helps to solve some configuration issues (without impacting the current legacy startup logs level/verbosity)


EDIT:

btw changing by this

  try {
    await prisma.$connect();

    success('Database connection successful.');
  } catch (e) {
    error(e.message);
    throw new Error('Unable to connect to the database.');
  }

dont add so much details

/app # node scripts/check-db.js
✓ DATABASE_URL is defined.
✗ Can't reach database server at `db:5432`

Please make sure your database server is running at `db:5432`.
✗ Unable to connect to the database.

there is a way to do some test using a given compose file (by hand)

  1. change docker compose and for umami entry add the following entrypoint:
    entrypoint: ["tail", "-f", "/dev/null"]
  2. then you could obtain root shell on it : docker exec --user root -it umami /bin/sh
  3. you could use vi to patch js and re-run check db like previously or dig sockets like below
/app # nc -z db 5432
# wait ^^ 
/app # echo $?
1

umami image cant reach the remote db port,
wheras (with 5432 port mapping added in compose), I'm able to connect to localhost:5432 from linux host

(I'm digging but not found for now: network, links, container_name,.. and pgsql is listening on IPv4 address "0.0.0.0", port 5432)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants