connecting to an external postgres server

Are you using our SaaS platform (Baserow.io) or self-hosting Baserow?

Self-hosted

If you are self-hosting, what version of Baserow are you running?

Version 1.31.1

If you are self-hosting, which installation method do you use to run Baserow?

Docker version 27.5.1, build 9f9e405

What are the exact steps to reproduce this issue?

I start baserow with the cpmmand :
docker run -d --name baserow -e DATABASE_URL=postgresql://postgres:mysecret@localhost:5432/baserow -e BASEROW_PUBLIC_URL=http://localhost -v baserow_data:/baserow/data -p 8085:80 -p 4439:443 --restart unless-stopped baserow/baserow:latest
I get the following error
connection to server at “localhost” (::1), port 5432 failed: Connection refused

the postgres server is started as a docker container:
docker run --name postgres_container -e POSTGRES_PASSWORD=mysecret -d -p 5432:5432 -v postgres_data:/var/lib/postgresql/data postgres

any ideas

Hi @jevylux, welcome to the community.

I think the issue here is that your baserow container cannot access the postgreSQL container via localhost:5432.

When using Docker containers, you need to either:

  1. Use Docker networking to connect the containers, or
  2. Use the host’s network configuration properly

If you already have the containers running, you’ll need to stop and remove them:

docker stop baserow postgres_container
docker rm baserow postgres_container

Then create a Docker network:

docker network create baserow-network

Start PostgreSQL container with the network:

docker run --name postgres_container \
  --network baserow-network \
  -e POSTGRES_PASSWORD=mysecret \
  -d \
  -p 5432:5432 \
  -v postgres_data:/var/lib/postgresql/data \
  postgres
  1. Start Baserow container with the network, updating the DATABASE_URL to use the container name:
docker run -d \
  --name baserow \
  --network baserow-network \
  -e DATABASE_URL=postgresql://postgres:mysecret@postgres_container:5432/baserow \
  -e BASEROW_PUBLIC_URL=http://localhost \
  -v baserow_data:/baserow/data \
  -p 8085:80 \
  -p 4439:443 \
  --restart unless-stopped \
  baserow/baserow:latest

Let me know if you still encounter any issues!