umami
umami copied to clipboard
`check-db.js` script should report the actual cause of a connection error
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 …)
It should report it now in the latest version.
?
https://github.com/umami-software/umami/blob/b006747a457b8284b2679d6611ddd16378f7dfaa/scripts/check-db.js#L41-L49
This is the version of the script I was using, the latest commit, and it does not report the actual cause of the problem.
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)
- change docker compose and for
umamientry add the following entrypoint:entrypoint: ["tail", "-f", "/dev/null"] - then you could obtain root shell on it :
docker exec --user root -it umami /bin/sh - 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
here umami image cant reach the remote db port,
EDIT2 🚀 :
On my side I was able found the root cause of my link issue, the OS update has changed some of the default ufw rules.
(src) It seems that the default DEFAULT_FORWARD_POLICY is set on DROP (in /etc/default/ufw) so docker links was not possible. Here is the fix in my case
sudo vi /etc/default/ufw
change the default policy
# DEFAULT_FORWARD_POLICY="DROP"
DEFAULT_FORWARD_POLICY="ACCEPT"
and reload firewall
sudo ufw reload
- then re-run your umami docker compose
hope this helps
@dpk, i fixed it in #2786, released in v2.13.0
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.