Introduction

Google Cloud Run is a managed container platform that automatically scales containerized applications. When a Cloud Run deployment fails, it typically manifests as a revision that never becomes ready, with the container failing health checks or crashing during startup. Deployment failures can stem from container image issues, port configuration mismatches, insufficient resources, startup probe timeouts, or missing service account permissions. Understanding the deployment lifecycle and common failure points is essential for rapid troubleshooting.

Symptoms

When Cloud Run deployment fails, you will observe these symptoms:

  • Revision stuck in "Not Ready" state indefinitely
  • Cloud Run service URL returns HTTP 502 or 503 errors
  • Container logs show repeated crash or restart attempts
  • Error messages in Google Cloud Console deployment dialog

Specific error messages you may encounter:

bash
Revision 'my-service-00001-abc' is not ready.
Container failed to start: health check failed on port 8080.
Error: containerterminated: The container failed to start within the allowed time.

In Cloud Console under Cloud Run > Revisions, the revision shows: - Status: "Not Ready" (red indicator) - Active revisions: 0 or previous revision still active - Traffic: 100% still routed to previous revision

Cloud Logging shows entries like: `` containerterminated: Container exited with error code 1 Health check failed: GET http://localhost:8080/ returned 404 Startup probe failed: connection refused to localhost:8080

Common Causes

  1. 1.Port mismatch - Container listens on different port than Cloud Run expects (default 8080)
  2. 2.Missing health check endpoint - Application lacks proper health check route
  3. 3.Startup timeout - Application takes longer than 10 minutes (default) to initialize
  4. 4.Insufficient memory - Container exceeds allocated memory during startup
  5. 5.Insufficient CPU - Startup requires more CPU than allocated
  6. 6.Invalid container image - Image doesn't exist, lacks permissions, or is malformed
  7. 7.Missing service account roles - Service account lacks required IAM permissions
  8. 8.Network connectivity issues - VPC connector misconfigured or unreachable
  9. 9.Environment variable errors - Missing or malformed environment variables
  10. 10.Entrypoint/cmd issues - Container command exits immediately or loops

Step-by-Step Fix

Step 1: Examine the Failed Revision

Get detailed information about the failed revision:

```bash # Describe the service to see revision status gcloud run services describe my-service --region=us-central1 --format=yaml

# List all revisions including failed ones gcloud run revisions list --service=my-service --region=us-central1

# Get specific revision details gcloud run revisions describe my-service-00001-abc --region=us-central1 --format=yaml ```

Check revision conditions in the output: ``yaml conditions: - type: Ready status: "False" reason: ContainerNotReady message: "Container failed to start"

Step 2: Analyze Container Logs

View the container logs to understand startup failure:

```bash # Stream logs for the service gcloud run logs read --service=my-service --region=us-central1 --limit=100

# Filter by revision gcloud logging read "resource.type=cloud_run_revision AND resource.labels.revision_name=my-service-00001-abc" --limit=50

# View all error logs gcloud logging read "resource.type=cloud_run_revision AND severity>=ERROR" --limit=100 ```

Common log patterns indicating specific issues:

``` # Port mismatch listen tcp: bind: address already in use Port 8080 is not listening

# Memory issue Runtime exited without providing a reason OOMKilled

# Application crash panic: runtime error fatal error: unexpected signal ```

Step 3: Verify Container Image and Port

Test the container image locally first:

```bash # Pull and run the image locally docker pull gcr.io/my-project/my-image:latest docker run -p 8080:8080 gcr.io/my-project/my-image:latest

# Check if the container responds on port 8080 curl http://localhost:8080/

# Check the container's listening port docker exec -it <container-id> netstat -tlnp ```

If the container listens on a different port, specify it during deployment:

bash
# Deploy with custom port
gcloud run deploy my-service \
  --image=gcr.io/my-project/my-image:latest \
  --region=us-central1 \
  --port=3000

Step 4: Configure Startup Probe and Health Check

Adjust startup timeout if application needs more initialization time:

bash
# Increase startup timeout (max 10 minutes)
gcloud run services update my-service \
  --region=us-central1 \
  --startup-cpu-boost \
  --timeout=600

Verify the health check endpoint exists. Cloud Run expects the container to respond on the root path / or you can configure a custom health check:

bash
# Ensure your application has health endpoint
curl http://localhost:8080/health
curl http://localhost:8080/_internal/healthcheck

Add health check endpoint to your application (example for Node.js): ``javascript // Express.js health check endpoint app.get('/', (req, res) => { res.status(200).send('OK'); });

Step 5: Adjust Resource Allocation

Increase memory and CPU if startup requires more resources:

bash
# Deploy with increased resources
gcloud run deploy my-service \
  --image=gcr.io/my-project/my-image:latest \
  --region=us-central1 \
  --memory=1Gi \
  --cpu=2 \
  --startup-cpu-boost

The --startup-cpu-boost option temporarily allocates more CPU during startup, which helps with initialization-heavy applications.

Step 6: Check Service Account Permissions

Verify the service account has required roles:

```bash # Get service account for Cloud Run gcloud run services describe my-service --region=us-central1 --format="value(spec.template.spec.serviceAccountName)"

# Check IAM bindings for the service account gcloud iam service-accounts get-iam-policy <service-account-email>

# Grant required roles if missing gcloud projects add-iam-policy-binding my-project \ --member="serviceAccount:<service-account-email>" \ --role="roles/cloudsql.client" ```

Common required roles: - roles/logging.logWriter - For writing logs - roles/secretmanager.secretAccessor - For accessing secrets - roles/cloudsql.client - For Cloud SQL connections

Step 7: Fix VPC Connector Issues

If using VPC access, verify the connector is healthy:

```bash # List VPC connectors gcloud compute networks vpc-access connectors list --region=us-central1

# Check connector status gcloud compute networks vpc-access connectors describe my-connector --region=us-central1

# Verify the connector is in "READY" state # Expected output: # state: READY ```

If connector is not ready: ``bash # Recreate the connector gcloud compute networks vpc-access connectors create my-connector \ --region=us-central1 \ --network=default \ --range=10.8.0.0/28

Step 8: Deploy with Correct Configuration

Perform a clean deployment with all corrected settings:

bash
gcloud run deploy my-service \
  --image=gcr.io/my-project/my-image:v2 \
  --region=us-central1 \
  --port=8080 \
  --memory=512Mi \
  --cpu=1 \
  --timeout=300 \
  --startup-cpu-boost \
  --set-env-vars="KEY=value,KEY2=value2" \
  --vpc-connector=my-connector \
  --service-account=my-sa@my-project.iam.gserviceaccount.com \
  --platform=managed \
  --allow-unauthenticated

Verification

After deployment, verify the service is healthy:

```bash # Get service URL SERVICE_URL=$(gcloud run services describe my-service --region=us-central1 --format="value(status.url)")

# Test the service endpoint curl -v $SERVICE_URL

# Check revision status gcloud run revisions list --service=my-service --region=us-central1 --format="table(name,status.conditions)"

# Verify traffic routing gcloud run services describe my-service --region=us-central1 --format="value(status.traffic)" ```

Expected successful output: `` Revision: my-service-00002-xyz Status: Ready Traffic: 100% URL: https://my-service-abc123.us-central1.run.app

Test multiple requests to ensure stability: ``bash # Send multiple requests for i in {1..10}; do curl -s -o /dev/null -w "%{http_code}\n" $SERVICE_URL; done

Expected: All responses return HTTP 200.

Prevention

To prevent future deployment failures:

  1. 1.Test locally first - Always run container locally with docker run before deploying
  2. 2.Use progressive rollouts - Deploy new revisions with traffic splitting:
  3. 3.```bash
  4. 4.gcloud run services update-traffic my-service --region=us-central1 --to-revisions=my-service-00002=10
  5. 5.`
  6. 6.Monitor startup time - Track initialization metrics:
  7. 7.```bash
  8. 8.gcloud logging read "resource.type=cloud_run_revision AND jsonPayload.message=~'startup'"
  9. 9.`
  10. 10.Validate environment variables - Check all required environment variables are set:
  11. 11.```bash
  12. 12.gcloud run services describe my-service --region=us-central1 --format="yaml(spec.template.spec.containers[0].env)"
  13. 13.`
  14. 14.Set up alerts - Create Cloud Monitoring alert for deployment failures:
  15. 15.```bash
  16. 16.gcloud alpha monitoring policies create \
  17. 17.--display-name="Cloud Run Deployment Failures" \
  18. 18.--condition-filter="resource.type=cloud_run_revision AND metric.type=run.googleapis.com/container/restart_count" \
  19. 19.--condition-threshold-value=3
  20. 20.`
  21. 21.Keep images small - Optimize container images for faster startup:
  22. 22.- Use multi-stage builds
  23. 23.- Minimize base image size
  24. 24.- Avoid unnecessary packages
  25. 25.Implement graceful shutdown - Handle SIGTERM properly for smooth redeployments
  • [Fix Fix Gcp Autoscaler Not Scaling Issue in GCP](fix-gcp-autoscaler-not-scaling)
  • [Fix Fix Gcp Backend Bucket Not Serving Issue in GCP](fix-gcp-backend-bucket-not-serving)
  • [Fix Fix Gcp Bigquery Dataset Access Denied Issue in GCP](fix-gcp-bigquery-dataset-access-denied)
  • [Fix Fix Gcp Bigquery Materialized View Refresh Failed Issue in GCP](fix-gcp-bigquery-materialized-view-refresh-failed)
  • [Fix Fix Gcp Bigquery Partition Modification Failed Issue in GCP](fix-gcp-bigquery-partition-modification-failed)

<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "GCP Cloud Run Service Deployment Failed", "description": "Fix Cloud Run deployment failures with step-by-step diagnosis of container startup, health checks, and resource configuration.", "url": "https://www.fixwikihub.com/fix-gcp-cloud-run-service-deployment-failed", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2025-12-13T02:41:28.645Z", "dateModified": "2025-12-13T02:41:28.645Z" } </script>