Brijesh
Brijesh9mo ago

Hi,

Hi, I have been trying to setup a self-hosted langfuse server. I followed the instructions on https://langfuse.com/docs/deployment/self-host. I installed postgresql (on docker as well) and verified that it works. Docker run returns following output:
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "langfuse", schema "public" at "localhost:5432"

Applying database migrations failed. This is mostly caused by the database being unavailable.
Exiting...
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "langfuse", schema "public" at "localhost:5432"

Applying database migrations failed. This is mostly caused by the database being unavailable.
Exiting...
I even tried another solution listed above by replacing host localhost with host.docker.internal, but this did not help. any ideas how to resolve this? thanks in advance!
6 Replies
Bryan
Bryan9mo ago
hi, are you running a docker compose on a single server that hosts the db and the langfuse app ?
Brijesh
Brijesh9mo ago
Yes, I'm running it on a single VM.
Bryan
Bryan9mo ago
okay then the host in the DATABASE_URL should not be localhost but the name of the docker service running the db you can send the docker compose file (removing confidential information first) so i can help you better
Brijesh
Brijesh9mo ago
Replacing it with my postgres image name (postgresdb) did not help, I got the same issue. I just ran the original postgres-alpine image with the below config, as such I didn't have to write a docker compose file.
docker run -d --name postgresdb \
-e POSTGRES_USER=<username> \
-e POSTGRES_PASSWORD=<password> \
-e POSTGRES_DB=langfuse \
-v langfuse-db:/var/lib/postgresql/data \
-p 5432:5432 postgres:13.8-alpine
docker run -d --name postgresdb \
-e POSTGRES_USER=<username> \
-e POSTGRES_PASSWORD=<password> \
-e POSTGRES_DB=langfuse \
-v langfuse-db:/var/lib/postgresql/data \
-p 5432:5432 postgres:13.8-alpine
After running the postgres db, I ran the following command to get langfuse up.
docker run --name langfuse \
-e DATABASE_URL=postgresql://<username>:<password>@postgresdb:5432/langfuse \
-e NEXTAUTH_URL=<url> \
-e NEXTAUTH_SECRET=<secret> \
-e SALT=<secret-2> \
-p 80:3000 \
-a STDOUT \
ghcr.io/langfuse/langfuse:latest
docker run --name langfuse \
-e DATABASE_URL=postgresql://<username>:<password>@postgresdb:5432/langfuse \
-e NEXTAUTH_URL=<url> \
-e NEXTAUTH_SECRET=<secret> \
-e SALT=<secret-2> \
-p 80:3000 \
-a STDOUT \
ghcr.io/langfuse/langfuse:latest
This is my VM architecture info: Linux office-ml-training 6.1.0-17-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 GNU/Linux My password and username also don't contain any special characters, which was apparently an issue with prisma for some people. The issue was with the networks the containers were in. Once I created a new network and added both containers to same network, it started working. Thanks for your help @Bryan .
Clemo
Clemo9mo ago
Thank you @Brijesh and @Bryan for debugging this & sharing the solution here so transparently!
Bryan
Bryan9mo ago
Oh yeah the network is necessary to have your docker containers communicate between each other ! I'm glad you managed to find the solution @Brijesh