Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityThe Blood of Dawnwalker Director Says 60 FPS Is Enough for This RPG(23.09.2026 um 14:37 Uhr)
Windows Tipps & SecurityMeyer Sound ernennt John McMahon zum Chief Operating Officer(23.09.2026 um 11:19 Uhr)
Windows Tipps & SecurityTouchscreen erweitert Grill-Sortiment am Point of Sale(23.09.2026 um 13:45 Uhr)
Windows Tipps & Security„When Worlds Unite“: ISE 2027 erweitert Messe und Programm(23.09.2026 um 13:45 Uhr)
Sichere ProgrammierungWhat Full-Stack AI Engineering Means in Real Projects(23.09.2026 um 14:00 Uhr)
Sichere ProgrammierungThe Internet Changes Everything (Slowly)(23.09.2026 um 14:09 Uhr)
Sichere ProgrammierungMAUI vs React Native vs Flutter vs Ionic(23.09.2026 um 14:09 Uhr)
Sichere ProgrammierungAI Tools Used in Modern Software Development(23.09.2026 um 14:22 Uhr)
Sichere ProgrammierungHealthAuditor — Website Health & SEO Audit Tool(23.09.2026 um 14:24 Uhr)
Windows Tipps & SecurityThe Blood of Dawnwalker Director Says 60 FPS Is Enough for This RPG(23.09.2026 um 14:37 Uhr)
Windows Tipps & SecurityMeyer Sound ernennt John McMahon zum Chief Operating Officer(23.09.2026 um 11:19 Uhr)
Windows Tipps & SecurityTouchscreen erweitert Grill-Sortiment am Point of Sale(23.09.2026 um 13:45 Uhr)
Windows Tipps & Security„When Worlds Unite“: ISE 2027 erweitert Messe und Programm(23.09.2026 um 13:45 Uhr)
Sichere ProgrammierungWhat Full-Stack AI Engineering Means in Real Projects(23.09.2026 um 14:00 Uhr)
Sichere ProgrammierungThe Internet Changes Everything (Slowly)(23.09.2026 um 14:09 Uhr)
Sichere ProgrammierungMAUI vs React Native vs Flutter vs Ionic(23.09.2026 um 14:09 Uhr)
Sichere ProgrammierungAI Tools Used in Modern Software Development(23.09.2026 um 14:22 Uhr)
Sichere ProgrammierungHealthAuditor — Website Health & SEO Audit Tool(23.09.2026 um 14:24 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

🐳 Fixing “FATAL: database does not exist” in PostgreSQL Docker (Healthcheck Mistake)

💡 Quick Stats Series: Docker Difficulty: Beginner / Intermediate Read Time: 5 min 🚀 The Setup I was building a .NET 8 Web API with PostgreSQL using Docker Compose. Everything looked fine: Containers were runni…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

💡 Quick Stats





  • Series: Docker


  • Difficulty: Beginner / Intermediate


  • Read Time: 5 min







🚀 The Setup



I was building a .NET 8 Web API with PostgreSQL using Docker Compose.



Everything looked fine:




  • Containers were running

  • Migrations were applied

  • API was responding

  • Database was created



But PostgreSQL logs were spamming this every 5 seconds:




FATAL: database "train_user" does not exist






The strange part?

The API was working perfectly.



So why was PostgreSQL complaining?







🧱 My Docker Setup



Here’s the relevant docker-compose.yml:




services:
postgres:
image: postgres:16
container_name: train-postgres
environment:
POSTGRES_DB: train_db
POSTGRES_USER: train_user
POSTGRES_PASSWORD: train_pass
ports:
- "5433:5432"
volumes:
- train_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U train_user"]
interval: 5s
timeout: 5s
retries: 5

api:
build: .
container_name: train-api
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
environment:
ConnectionStrings__DefaultConnection: "Host=postgres;Port=5432;Database=train_db;Username=train_user;Password=train_pass"

volumes:
train_pgdata:






Looks correct at first glance, right?









🔎 The Clue



The error appeared exactly every 5 seconds.



That matched this line:




interval: 5s






That meant something inside the healthcheck was failing.









🧠 Understanding PostgreSQL Default Behavior



The healthcheck command was:




pg_isready -U train_user






Here’s the important PostgreSQL rule:




If you don’t specify a database, PostgreSQL assumes:

Database name = Username




So this command was actually trying to connect to:




Database: train_user






But my actual database (created using POSTGRES_DB) was:




train_db






That mismatch caused:




FATAL: database "train_user" does not exist






Every 5 seconds.









✅ The Fix



Simply specify the correct database in the healthcheck:




healthcheck:
test: ["CMD-SHELL", "pg_isready -U train_user -d train_db"]
interval: 5s
timeout: 5s
retries: 5






Restart containers:




docker compose down
docker compose up --build






And the log spam disappeared instantly.









🎯 Key Lessons






1️⃣ Container Name ≠ Database Name
























Type Example
Container name train-postgres
Service name (Docker DNS) postgres
Database name train_db


They are three completely different things.









2️⃣ PostgreSQL Defaults Can Trick You



If you connect without -d, PostgreSQL uses:




Database = Username






Always specify the database explicitly.









3️⃣ Healthchecks Can Mislead You



A failing healthcheck can:




  • Spam logs

  • Confuse debugging

  • Make you suspect the wrong issue

  • Hide the real root cause



Timing patterns in logs are powerful debugging clues.









🏁 Final State



After the fix:




  • PostgreSQL container → Healthy

  • .NET API → Running

  • Database → Correct

  • Logs → Clean

  • No more FATAL errors









💡 Bonus Improvement



You can make the healthcheck dynamic:




test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER -d $POSTGRES_DB"]






This avoids hardcoding values.









🔥 Final Thought



This wasn’t a Docker problem.



It was:




  • A PostgreSQL default behavior

  • Combined with a small configuration oversight



Sometimes debugging is just about understanding how tools behave by default.






If this helped you, feel free to connect or share your experience debugging Docker setups 👋

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 🐳 Fixing “FATAL: database does not exist” in PostgreSQL Docker (Healthcheck Mistake)

Thematisch verwandte Begriffe: Fixing, FATAL, database, does · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-5695 | Arbitrary file upload vulnerability due to a lack of proper validation in…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick