Skip to content
Latchkey

Lightsail container service deployment failed in CI

create-container-service-deployment starts the new container and probes its health check on the public endpoint. If the container does not become healthy, the deployment state goes to FAILED and the previous deployment stays active.

What this error means

After create-container-service-deployment, the service shows the new deployment state as FAILED and the container log shows the app exiting or the health check path returning non-2xx.

lightsail
{ "deployment": { "version": 7, "state": "FAILED" } }
Container "web" failed health check on path "/" port 80.

Common causes

The container does not listen on the mapped port

The public endpoint maps to a container port; if the app binds a different port or only localhost, the health check cannot reach it.

A failing health check path

The configured health check path returns a non-2xx, or the app crashes on boot due to missing environment values, so the deployment is marked FAILED.

How to fix it

Match the endpoint port and health path

  1. Set the public endpoint container port to the port the app binds.
  2. Point the health check path at a route that returns 200.
  3. Redeploy and confirm the deployment reaches ACTIVE.
containers.json
{ "publicEndpoint": { "containerName": "web", "containerPort": 80,
  "healthCheck": { "path": "/healthz", "successCodes": "200" } } }

Inspect the container log

Read the container log to see startup crashes or missing configuration before retrying.

Terminal
aws lightsail get-container-log \
  --service-name myapp --container-name web

How to prevent it

  • Expose a 200 health route and reference it in the endpoint config.
  • Bind the app to the mapped container port on all interfaces.
  • Provide all required environment values in the deployment.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →