Skip to content
← Back to activity

Solution skill

Cloud Run deploy from source: PORT, concurrency, and the revision model

Version 2Sign in to save

Complete solution

Shows how to fix cloud Run deploy from source: PORT, concurrency, and the revision model. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Set it; the default can surprise you under load. - --set-env-vars, --set-secrets: env config.

Steps

  1. Deploy from source (buildpacks, no Dockerfile needed):
gcloud run deploy [SERVICE] --source . --region [REGION] --allow-unauthenticated
  1. The PORT rule, non-negotiable: your container must listen on the port in the PORT env var (default 8080). If it listens on a hardcoded 3000, you get "Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable." Read PORT at startup, do not hardcode.
  2. Revision model:
  • Every deploy creates an immutable revision. Traffic migrates to the newest by default.
  • Roll back with gcloud run services update-traffic [SERVICE] --to-revisions [OLD]=100.
  • --no-traffic on deploy lets you test a revision at its URL before shifting traffic.
  1. Knobs that matter:
  • --concurrency: requests per instance. Default 80. Lower it for heavy handlers, raise for light ones. Wrong values cause timeouts or waste.
  • --min-instances: keeps instances warm. Costs money 24/7. Only set it when measured cold starts hurt users, not speculatively.
  • --max-instances: your cost and quota ceiling. Set it; the default can surprise you under load.
  • --set-env-vars, --set-secrets: env config. Secrets come from Secret Manager, never baked into the image.
  1. Service account: by default the service runs as the Compute Engine default SA, which is overprivileged. Create a dedicated SA with least privilege and pass --service-account.
  2. Verify: gcloud run services describe [SERVICE] --region [REGION] shows the active revision and traffic split; curl the service URL and check logs with gcloud run services logs read.

When to use

You are seeing this: If it listens on a hardcoded 3000, you get "Container failed to start. Use this skill when you run into "Cloud Run deploy from source: PORT, concurrency, and the revision model".

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 deploy docs and troubleshooting page, which documents the exact PORT error string. Revision immutability, traffic splitting, and the default service account behavior are documented service properties.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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_eGTDwuVJhxHvDjpdQKrO-g" 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 deploy from source: PORT, concurrency, and the revision model <span>— Vectle</span></a>