{"record":{"id":"d7502329fda8ae78","repo":"GoogleContainerTools/skaffold","slug":"port-forward-run-proxy-start-error","errorCode":"PORT_FORWARD_RUN_PROXY_START_ERROR","errorMessage":"unable to start port forward: %w","messagePattern":"unable to start port forward: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/cloudrun/accessor.go","lineNumber":168,"sourceCode":"\t\treturn nil\n\t}\n\tfor _, resource := range r.resources.resources {\n\t\tif resource.port == 0 {\n\t\t\tport := retrieveAvailablePort(\"localhost\", 8080, r.resources.forwardedPorts)\n\t\t\tresource.port = port\n\t\t}\n\t\tif !resource.started {\n\t\t\teventV2.TaskInProgress(constants.PortForward, \"port forward URLs\")\n\t\t\t// has not been started yet\n\t\t\tcctx, cancel := context.WithCancel(ctx)\n\t\t\toutput.Yellow.Fprintf(out, \"Forwarding service %s to local port %d\\n\", resource.name.String(), resource.port)\n\t\t\tcmd := exec.CommandContext(cctx, \"gcloud\", getGcloudProxyArgs(resource.name, resource.port)...)\n\t\t\tcmd.Stdout = out\n\t\t\tcmd.Stderr = out\n\t\t\tresource.cancel = cancel\n\t\t\tif err := cmd.Start(); err != nil {\n\t\t\t\teventV2.TaskFailed(constants.PortForward, err)\n\t\t\t\treturn sErrors.NewError(fmt.Errorf(\"unable to start port forward: %w\", err), &proto.ActionableErr{ErrCode: proto.StatusCode_PORT_FORWARD_RUN_PROXY_START_ERROR})\n\t\t\t}\n\t\t\tgo func() {\n\t\t\t\terr := cmd.Wait()\n\t\t\t\tif err != nil {\n\t\t\t\t\teventV2.TaskFailed(constants.PortForward, err)\n\t\t\t\t} else {\n\t\t\t\t\teventV2.TaskSucceeded(constants.PortForward)\n\t\t\t\t}\n\t\t\t}()\n\t\t\teventV2.PortForwarded(int32(resource.port), schemautil.FromInt(443), \"\", \"\", resource.name.Project, \"\", \"run-service\", resource.name.Service, resource.name.String())\n\t\t\tresource.started = true\n\t\t\tresource.cmd = cmd\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc getGcloudProxyArgs(resource RunResourceName, port int) []string {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/cloudrun/accessor.go#L150-L186","documentation":"In `runProxyForwarder.Start`, skaffold spawns a background `gcloud ... proxy` process (via `exec.CommandContext(...).Start()`) for each Cloud Run resource being port-forwarded. If the process fails to *start* (as opposed to exiting later), the error is wrapped as 'unable to start port forward: %w' with code PORT_FORWARD_RUN_PROXY_START_ERROR and the port-forward task is marked failed.","triggerScenarios":"`cmd.Start()` fails while iterating over `r.resources.resources` — e.g. the exec context was already cancelled (`cctx` cancelled), the gcloud binary disappeared between the install check and the exec, OS resource limits (fork/exec failures), or invalid arguments built by `getGcloudProxyArgs`.","commonSituations":"User hits Ctrl-C / the context is cancelled while forwards are being set up; out-of-memory or PID exhaustion in constrained CI containers; a corrupted or partially-installed gcloud SDK; port numbers that cause gcloud to reject args immediately.","solutions":["Read the wrapped cause (`%w`) at the end of the message to identify the underlying exec failure and fix it","Re-run after cancelling: transient context-cancellation during startup is expected; restart `skaffold dev`","Check available resources (PID/memory limits) if the cause is 'fork/exec: cannot allocate memory' or similar","Reinstall/repair the gcloud SDK if the cause indicates a missing or damaged binary","Verify the resource name and port used for the proxy (from the skaffold Cloud Run config) are valid"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the proxy command can at least be resolved and args look sane before spawning\nif _, err := exec.LookPath(\"gcloud\"); err != nil {\n\treturn fmt.Errorf(\"gcloud unavailable, cannot start Cloud Run proxy: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := forwarder.Start(ctx, out); err != nil {\n\tvar sErr *sErrors.Error\n\tif errors.As(err, &sErr) && sErr.Status().ErrCode == proto.StatusCode_PORT_FORWARD_RUN_PROXY_START_ERROR {\n\t\tlog.Warnf(\"Cloud Run proxy failed to start: %v — retrying once\", err)\n\t\ttime.Sleep(2 * time.Second)\n\t\treturn forwarder.Start(ctx, out)\n\t}\n\treturn err\n}","preventionTips":["Don't cancel the skaffold context while port-forwards are initializing","Ensure CI containers have adequate PID/memory limits for spawned processes","Keep the gcloud SDK installation intact (don't delete SDK files while skaffold runs)","Validate Cloud Run resource names and ports in skaffold config before running dev"],"tags":["cloud-run","port-forwarding","gcloud","process-exec"],"backgroundTag":"process-start-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}