GitHub Actions service container options health-cmd invalid
Service containers can declare a health check via the options field using Docker run flags like --health-cmd. A malformed health-cmd (bad quoting, wrong command) means the container never reports healthy, and dependent steps wait or fail.
What this error means
A service container never reaches a healthy state and the job stalls or fails waiting on it.
github-actions
services:
db:
image: postgres:16
options: >-
--health-cmd pg_isready # missing quoting/db user -> health check never passesCommon causes
health-cmd not properly quoted
A multi-word health command needs correct quoting in the options string.
Health command itself fails
If the command exits non-zero (wrong user/db), the container is reported unhealthy forever.
How to fix it
Quote and complete the health command
- Wrap the command and add health interval/timeout/retries.
- Ensure the command actually succeeds for the service config.
.github/workflows/ci.yml
services:
db:
image: postgres:16
env:
POSTGRES_PASSWORD: pass
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5Test the health command locally
- Run the same docker run --health-cmd locally to confirm it returns 0.
- Adjust user, database, or port until the check passes.
How to prevent it
- Always quote multi-word health-cmd and add interval/retries.
- Validate the health command outside Actions first.
Related guides
GitHub Actions Container Job "options" Invalid or IgnoredFix GitHub Actions container job options errors - unsupported docker flags in jobs.<id>.container.options, or…
GitHub Actions Service Container Unhealthy - Postgres/Redis Not ReadyFix GitHub Actions service containers (Postgres, Redis, MySQL) that never become healthy - missing health che…
GitHub Actions service container port not exposed to stepsFix steps that cannot reach a service container because the port mapping was not declared or the wrong host i…