{"record":{"id":"e092ba83d5a1d9f0","repo":"docker/compose","slug":"application-not-healthy-after-s","errorCode":null,"errorMessage":"application not healthy after %s","messagePattern":"application not healthy after (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/start.go","lineNumber":90,"sourceCode":"\n\tif options.Wait {\n\t\tdepends := types.DependsOnConfig{}\n\t\tfor _, s := range project.Services {\n\t\t\tdepends[s.Name] = types.ServiceDependency{\n\t\t\t\tCondition: getDependencyCondition(s, project),\n\t\t\t\tRequired:  true,\n\t\t\t}\n\t\t}\n\t\tif options.WaitTimeout > 0 {\n\t\t\twithTimeout, cancel := context.WithTimeout(ctx, options.WaitTimeout)\n\t\t\tctx = withTimeout\n\t\t\tdefer cancel()\n\t\t}\n\n\t\terr = s.waitDependencies(ctx, project, project.Name, depends, containers, 0)\n\t\tif err != nil {\n\t\t\tif errors.Is(ctx.Err(), context.DeadlineExceeded) {\n\t\t\t\treturn fmt.Errorf(\"application not healthy after %s\", options.WaitTimeout)\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// getDependencyCondition checks if service is depended on by other services\n// with service_completed_successfully condition, and applies that condition\n// instead, or --wait will never finish waiting for one-shot containers\nfunc getDependencyCondition(service types.ServiceConfig, project *types.Project) string {\n\tfor _, services := range project.Services {\n\t\tfor dependencyService, dependencyConfig := range services.DependsOn {\n\t\t\tif dependencyService == service.Name && dependencyConfig.Condition == types.ServiceConditionCompletedSuccessfully {\n\t\t\t\treturn types.ServiceConditionCompletedSuccessfully\n\t\t\t}\n\t\t}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/start.go#L72-L108","documentation":"With --wait (options.Wait dependencies), compose waits for dependency health/success conditions under an optional WaitTimeout. When the context deadline expires before waitDependencies finishes, the generic deadline error is translated into this user-facing timeout message including the configured duration.","triggerScenarios":"Running up with wait flags and a wait timeout where a depended-on service never reaches healthy (or service_completed_successfully) within options.WaitTimeout — e.g. a database that fails its healthcheck or an app that crashes on boot.","commonSituations":"Healthcheck intervals too aggressive for slow-starting services; wrong healthcheck command that never succeeds; dependency stuck waiting on another unhealthy dependency; timeout set lower than realistic startup time in CI.","solutions":["Inspect why the dependency is unhealthy: docker compose ps, docker compose logs <service>, and docker inspect the healthcheck status.","Fix or relax the healthcheck (correct command, larger interval/retries/start_period) so it turns healthy when the service is actually ready.","Increase the wait timeout (--wait-timeout) to exceed realistic startup time.","Fix the dependent service's crash (missing config, bad credentials) that prevents completion."],"exampleFix":"# before\nservices:\n  db:\n    image: postgres\n    healthcheck:\n      test: [\"CMD\", \"pg_isready\"]           # flaky/too strict\n      interval: 2s\n      retries: 1\n\n# after\nservices:\n  db:\n    image: postgres\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U $$POSTGRES_USER\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n      start_period: 20s","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := composeService.Start(ctx, projectName, api.StartOptions{Wait: true, WaitTimeout: 2 * time.Minute})\nif err != nil {\n    if strings.Contains(err.Error(), \"application not healthy after\") {\n        // inspect logs/health of dependencies, fix healthcheck, optionally retry with longer timeout\n    }\n    return err\n}","preventionTips":["Tune healthchecks (start_period, retries) to the service's real startup time.","Set --wait-timeout generously in CI where cold caches slow startup.","Smoke-test healthcheck commands manually before wiring them into compose."],"tags":["compose","wait","healthcheck","timeout","dependencies"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}