I am facing an issue where the Immich server container keeps failing with:
Error: getaddrinfo EAI_AGAIN database
hostname: ‘database’
Even though my Docker compose file is configured correctly with:
DATABASE_HOST=postgres
DATABASE_PORT=5432
and there is no reference to “database” anywhere in my compose or .env file.
System Setup:
- Windows 10/11
- Docker Desktop using WSL2 backend
- WSL2 Ubuntu-20.04
- Running docker compose inside ~/immich as user “giri”
All containers start normally:
postgres Up
redis Up
immich_server Up (health: starting → crash loop)
immich_web Up
immich_ml Up
But Immich server keeps restarting with DNS resolution errors.
Full Error:
Error: getaddrinfo EAI_AGAIN database
errno: -3001
code: ‘EAI_AGAIN’
syscall: ‘getaddrinfo’
hostname: ‘database’
Environment inside the container (output of printenv):
DATABASE_URL=postgresql://immich:ImmichDBPass123@postgres:5432/immich
The URL is correct, but the server still tries to resolve the hostname “database”.
It looks like some old internal default environment variable such as DATABASE_HOST=database is still being used even after deleting all containers and images.
docker-compose.yml (simplified):
services:
postgres:
image: postgres:15
environment:
POSTGRES_USER=${POSTGRES_USER}
POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
POSTGRES_DB=${POSTGRES_DB}
redis:
image: redis:7
command=["redis-server","--requirepass","${REDIS_PASSWORD}"]
immich-server:
image: ghcr.io/immich-app/immich-server:release
environment:
DATABASE_HOST=postgres
DATABASE_PORT=5432
DATABASE_USER=${POSTGRES_USER}
DATABASE_PASSWORD=${POSTGRES_PASSWORD}
DATABASE_NAME=${POSTGRES_DB}
REDIS_HOST=redis
REDIS_PASSWORD=${REDIS_PASSWORD}
Important point:
There is no reference to the hostname “database” anywhere in the new compose file.
What I have already tried:
- Removed all containers (docker rm -f …)
- Removed all images (docker rmi …)
- Recreated the .env file
- Recreated docker-compose.yml from scratch
- Deleted old folders
- Ran docker compose up --force-recreate
- Fresh WSL installation
- Fresh Docker Desktop installation
- Confirmed correct docker context
- Verified that “postgres” resolves correctly on the internal network
But Immich server logs still show:
hostname: ‘database’
Expected behavior:
Immich server should connect to Postgres using:
DATABASE_HOST=postgres
Actual behavior:
Immich server ignores DATABASE_HOST and falls back to “database”, causing DNS failure and crashing repeatedly.
Question:
Why does Immich server continue trying to resolve “database” even after:
- full reset
- new compose
- new env
- deleted images
- deleted containers
Is this:
- an internal default inside the image?
- a Docker Desktop environment caching issue?
- WSL2 environment override?
- leftover metadata or labels?
- something else entirely?
Looking for guidance on how to completely remove any old configuration and ensure Immich uses the correct DATABASE_HOST value.
Thanks.