Local vs Docker Databases

Choose where your database runs and configure DATABASE_URL correctly.

When running Tzylo Auth CE, one of the first decisions you make is where your database should run.

There is no single correct choice. The right setup depends on your development workflow and deployment environment.

Common database setups

  • Database running locally on your machine
  • Database running in Docker
  • Database running in Docker Compose with Auth CE

Database running locally

In this setup, the database runs directly on your machine (for example via a local Postgres or MySQL installation).

This is common during early development.

Auth CE running locally

If both Auth CE and the database run on your machine, use localhost :

DATABASE_URL
DATABASE_URL=postgresql://user:pass@localhost:5432/authdb

Auth CE running in Docker

If Auth CE runs inside Docker and the database runs on your machine, localhost will not work.

Use host.docker.internal instead:

DATABASE_URL
DATABASE_URL=postgresql://user:pass@host.docker.internal:5432/authdb

Database running in Docker

In this setup, the database runs in a Docker container.

This avoids installing database software directly on your machine and keeps environments consistent.

Database container with exposed port

If the database container exposes a port, and Auth CE runs locally, you can still use localhost:

DATABASE_URL
DATABASE_URL=postgresql://user:pass@localhost:5432/authdb

Docker forwards the container port to your machine.

Both services in Docker Compose

This is the recommended setup for most projects.

When using Docker Compose, services communicate using service names:

DATABASE_URL
DATABASE_URL=postgresql://auth:auth@db:5432/authdb

Here, db is the database service name indocker-compose.yml.

Do not use localhost between services in Docker Compose.

Which setup should you use?

  • Local DB – fast iteration, simple setup
  • Docker DB – consistent environments, easier cleanup
  • Compose – closest to production, recommended long-term

Common mistakes

  • Using localhost inside Docker
  • Forgetting to expose database ports
  • Mismatched database credentials
  • Assuming Docker Compose uses the host network
Most database connection issues are caused by incorrect assumptions about where services are running.