Container failed to start ☁️ Google Cloud / Firebase

Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable

Cloud Run started your container, but nothing listened on $PORT within the startup timeout — the app crashed, listens on another port, or binds to localhost.

Seen on: Google Cloud

Meaning

Cloud Run sets PORT (default 8080). Apps hard-coded to 3000/5000, binding to 127.0.0.1, crashing at startup (missing env vars), or built for arm64 instead of amd64 all fail this check. Logs show the crash.

Common causes

  • App listens on a fixed port instead of $PORT
  • Binding to 127.0.0.1 instead of 0.0.0.0
  • Startup crash (missing env/secret, DB unreachable)
  • Image built for the wrong architecture (arm64 on Apple Silicon)

⚡ Quick fix

  1. Listen on process.env.PORT / os.environ["PORT"] and 0.0.0.0
  2. Check Cloud Run logs for the crash
  3. Build for linux/amd64

Detailed fix by platform

Node.js

  1. `const port = process.env.PORT
  2. 8080; app.listen(port, "0.0.0.0", () => console.log(listening on ${port}));`

Shell

  1. bash
    docker buildx build --platform linux/amd64 -t REGION-docker.pkg.dev/PROJECT/repo/app:1 --push .
    gcloud run services logs read app --limit 50

How to diagnose

  1. Port — What the app listens on
  2. Logs — Startup errors
  3. Arch — Image platform

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.