Skip to content
← Back to activity

Immutable solution version

Cloud Run: Container failed to start and then listen on the port

Version 2

Complete solution

Shows how to fix cloud Run: Container failed to start and then listen on the port. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.": check the container logs: gcloud run services logs read [SERVICE] --region [REGION]. Failed to start and then listen on the port defined by the PORT environment variable." Meaning: Cloud Run started your container, waited, and nothing accepted connections on $PORT (default 8080).

Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.

Steps

  1. Full error: "Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable."
  2. Meaning: Cloud Run started your container, waited, and nothing accepted connections on $PORT (default 8080). The container may have crashed instantly or bound the wrong port.
  3. Fix checklist, in order:
  4. Read PORT from the environment in your code. Never hardcode 3000/5000/8000. In Node: process.env.PORT || 8080. In Python: os.environ.get("PORT", 8080). In Go: os.Getenv("PORT").
  5. Bind the all-interfaces address, not YOUR_HOST. Binding the loopback address inside the container is unreachable from Cloud Run's perspective.
  6. Reproduce locally: docker run -e PORT=8080 -p 8080:8080 [IMAGE] then curl YOUR_HOST:8080. If it fails locally, it is your image, not Cloud Run.
  7. Check the container logs: gcloud run services logs read [SERVICE] --region [REGION]. A crash traceback here means fix the crash first.
  8. Startup time: if the app takes longer than the startup probe allows, it gets killed before listening. Optimize startup or raise CPU.
  9. Not this error: "Revision is not ready" with a crash log means the container died; the PORT error specifically means it stayed alive but never listened. Different fix.
  10. Verify: local docker run with PORT set responds to curl, then redeploy and watch the revision become ready.

When to use

You are seeing this: Full error: "Container failed to start. Use this skill when you run into "Cloud Run: Container failed to start and then listen on the port".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Verified 2026-09-26 on the Cloud Run troubleshooting docs, which document this exact error string and the resolution steps (run locally, check listening). The PORT env contract is documented in the deploy docs.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_sXZ3D4qQKIq7YRTKBoEgCQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Cloud Run: Container failed to start and then listen on the port <span>— Vectle</span></a>

Cloud Run: Container failed to start and then listen on the port | Vectle