{"record":{"id":"7439a4596f373a99","repo":"Dokploy/dokploy","slug":"dokploy-postgres-container-not-found-7439a4","errorCode":null,"errorMessage":"Dokploy Postgres container not found","messagePattern":"Dokploy Postgres container not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/server/src/utils/restore/web-server.ts","lineNumber":94,"sourceCode":"\t\t\tif (hasGzFile.includes(\"database.sql.gz\")) {\n\t\t\t\temit(\"Found compressed database file, decompressing...\");\n\t\t\t\tawait execAsync(`cd ${tempDir} && gunzip database.sql.gz`);\n\t\t\t}\n\n\t\t\t// Verify database file exists\n\t\t\tconst { stdout: hasSqlFile } = await execAsync(\n\t\t\t\t`ls ${tempDir}/database.sql || true`,\n\t\t\t);\n\t\t\tif (!hasSqlFile.includes(\"database.sql\")) {\n\t\t\t\tthrow new Error(\"Database file not found after extraction\");\n\t\t\t}\n\n\t\t\tconst { stdout: postgresContainer } = await execAsync(\n\t\t\t\t`docker ps --filter \"name=dokploy-postgres\" --filter \"status=running\" -q | head -n 1`,\n\t\t\t);\n\n\t\t\tif (!postgresContainer) {\n\t\t\t\tthrow new Error(\"Dokploy Postgres container not found\");\n\t\t\t}\n\n\t\t\tconst postgresContainerId = postgresContainer.trim();\n\n\t\t\t// Drop and recreate database\n\t\t\temit(\"Disconnecting all users from database...\");\n\t\t\tawait execAsync(\n\t\t\t\t`docker exec ${postgresContainerId} psql -U dokploy postgres -c \"SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'dokploy' AND pid <> pg_backend_pid();\"`,\n\t\t\t);\n\n\t\t\temit(\"Dropping existing database...\");\n\t\t\tawait execAsync(\n\t\t\t\t`docker exec ${postgresContainerId} psql -U dokploy postgres -c \"DROP DATABASE IF EXISTS dokploy;\"`,\n\t\t\t);\n\n\t\t\temit(\"Creating fresh database...\");\n\t\t\tawait execAsync(\n\t\t\t\t`docker exec ${postgresContainerId} psql -U dokploy postgres -c \"CREATE DATABASE dokploy;\"`,","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/utils/restore/web-server.ts#L76-L112","documentation":"The web-server restore needs the running Dokploy Postgres container to import database.sql into. It runs docker ps filtered by name=dokploy-postgres and status=running, and throws when no container matches.","triggerScenarios":"Postgres container stopped or restarting, container renamed, Docker not running on the host, or filter mismatch because the container runs under a different name/compose project.","commonSituations":"Host rebooted and the stack didn't come up; user renamed the container; running restore on a remote/standalone server where the local dokploy-postgres doesn't exist.","solutions":["Start the container: docker start dokploy-postgres (or docker compose up -d in the dokploy directory)","Confirm the exact name: docker ps -a | grep postgres","Verify the Docker daemon is reachable from the server process","If the container name differs, align it or update the filter/restore logic"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const running = execSync('docker ps --filter name=dokploy-postgres --filter status=running -q').toString().trim();\nif (!running) throw new Error('Start dokploy-postgres before restoring');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add healthchecks so the DB container is up before restore jobs","Monitor the compose stack after host reboots"],"tags":["docker","postgres","restore","container-not-found"],"backgroundTag":"docker-container-not-found","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}