Debug Gcloud Run Deploy Hangs | Generated by AI
Question: The gcloud run deploy command is stuck / hanging, does gcloud have a verbose option?
Answer:
Yes, gcloud supports a --verbosity flag to get more detailed output, which is very useful for debugging when a deployment hangs or takes unusually long.
How to add verbosity
Run your command with one of these (higher = more output):
gcloud run deploy blog-server \
--source . \
--region asia-northeast1 \
--allow-unauthenticated \
--port 8080 \
--memory 1Gi \
--verbosity=debug
Common levels (from most to least verbose):
--verbosity=debug→ shows detailed steps, API calls, retries, etc. (recommended for troubleshooting hangs)--verbosity=info→ more than default, but cleaner--verbosity=warning→ default-ish--verbosity=error→ minimal
You can also set it globally (affects all gcloud commands):
gcloud config set core/verbosity debug
(Reset later with gcloud config set core/verbosity warning or just omit --verbosity.)
Why it might be stuck / hanging on --source .
The --source . flag triggers:
- Source upload to Cloud Build
- Automatic container build (using your
Dockerfileor Cloud Buildpacks if no Dockerfile) - Deploy to Cloud Run
Common reasons for long hangs (especially “Uploading sources…” or “Building and deploying…”):
- Large project / many files — Maven downloads dependencies during build, large
target/folder, git history, node_modules, etc. → upload takes forever.- Fix idea: Add a
.gcloudignorefile (like.gitignore) to exclude unnecessary files/folders (e.g.target/,.git/,node_modules/,logs/). Example minimal.gcloudignore:.git target/ *.log node_modules/ .mvn/
- Fix idea: Add a
- Slow internet / large upload — Especially if you’re on a slow connection or VPN.
- Build is slow — If using Maven, it might be resolving dependencies, compiling, tests, etc. (even if you have
Dockerfile, Cloud Build still runs it). - Known occasional Cloud Build / Cloud Run backend delays — Sometimes it hangs 10–30+ minutes then fails with “deadline exceeded” or succeeds late.
- Permissions / quota issues — Missing roles for Cloud Build or Artifact Registry.
Quick workarounds / faster alternatives
- Build & push image manually (avoids source upload slowness):
docker build -t gcr.io/$(gcloud config get-value project)/blog-server:latest . docker push gcr.io/$(gcloud config get-value project)/blog-server:latest gcloud run deploy blog-server \ --image gcr.io/$(gcloud config get-value project)/blog-server:latest \ --region asia-northeast1 \ --allow-unauthenticated \ --port 8080 \ --memory 1GiThis is usually much faster for repeated deploys.
-
Use Artifact Registry instead of gcr.io (modern recommendation): Create repo:
gcloud artifacts repositories create my-repo --repository-format=docker --location=asia-northeast1Then tag/push:asia-northeast1-docker.pkg.dev/YOUR-PROJECT/my-repo/blog-server:latest - Check Cloud Build logs (even if CLI hangs):
- Go to https://console.cloud.google.com/cloud-build/builds
- Find the latest build triggered by your deploy → see detailed steps / errors.
- Add
--asyncto make CLI return immediately:gcloud run deploy ... --asyncThen monitor in console or with
gcloud run services describe blog-server --region asia-northeast1
Run with --verbosity=debug first — it will show exactly where it’s spending time (e.g., uploading X MB, waiting for build step Y). If it still hangs forever (>20–30 min), cancel (Ctrl+C), clean up unnecessary files with .gcloudignore, or switch to manual image push.
References:
- gcloud CLI overview – verbosity flag
-
[Deploy services from source code Cloud Run](https://docs.cloud.google.com/run/docs/deploying-source-code) - gcloud run deploy reference
- Troubleshoot Cloud Run issues