{"record":{"id":"bd88826bc9d50234","repo":"GoogleContainerTools/skaffold","slug":"exiting-dev-mode-because-first-deploy-failed-w","errorCode":null,"errorMessage":"exiting dev mode because first deploy failed: %w","messagePattern":"exiting dev mode because first deploy failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/dev.go","lineNumber":348,"sourceCode":"\t\terrT := term.WaitForKeyPress()\n\t\tif errT != nil {\n\t\t\treturn errT\n\t\t}\n\t\t// The previous Render Stage could succeed even for kubernetes resource with unknown fields, this will lead to failure in Deploy Stage\n\t\t// users need to fix the problems in their manifests, and skaffold needs to re-render them before re-running Deploy Stage in this case.\n\t\tfor manifests, err = r.Render(ctx, out, r.Builds, false); err != nil; manifests, err = r.Render(ctx, out, r.Builds, false) {\n\t\t\tlog.Entry(ctx).Warnf(\"Failed to Render, please fix the error and press any key to continue. %v\", err)\n\t\t\terrT := term.WaitForKeyPress()\n\t\t\tif errT != nil {\n\t\t\t\treturn errT\n\t\t\t}\n\t\t}\n\t}\n\tif err != nil {\n\t\tevent.DevLoopFailedInPhase(r.devIteration, constants.Deploy, err)\n\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\tendTrace()\n\t\treturn fmt.Errorf(\"exiting dev mode because first deploy failed: %w\", err)\n\t}\n\tr.deployManifests = manifests\n\n\tdefer r.deployer.GetAccessor().Stop()\n\n\tif err := r.deployer.GetAccessor().Start(ctx, out); err != nil {\n\t\tlog.Entry(ctx).Warn(\"Error starting resource accessor:\", err)\n\t}\n\tif err := r.deployer.GetDebugger().Start(ctx); err != nil {\n\t\tlog.Entry(ctx).Warn(\"Error starting debug container notification:\", err)\n\t}\n\t// Start printing the logs after deploy is finished\n\tif err := r.deployer.GetLogger().Start(ctx, out); err != nil {\n\t\treturn fmt.Errorf(\"starting logger: %w\", err)\n\t}\n\n\tg := getTransposeGraph(artifacts)\n\t// Watch artifacts","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/dev.go#L330-L366","documentation":"Skaffold's Dev() aborts the entire dev loop when the very first deploy attempt fails. It records a DevLoop failure event for the Deploy phase and wraps the underlying deploy error with 'exiting dev mode because first deploy failed'. Because a first deploy failure means the dev loop has nothing to watch or sync against, Skaffold stops instead of retrying.","triggerScenarios":"Calling `skaffold dev` when the initial `deploy` step returns an error: the deployer (kubectl/helm/kpt) fails to apply manifests, the cluster is unreachable, images referenced by manifests are missing, or the deployer returns a non-nil error on the first iteration.","commonSituations":"No kubectl context / cluster unreachable (VPN off, wrong kubeconfig); image not pushed to the registry the cluster can pull from; invalid or non-existent namespace; helm release chart errors; RBAC denials on first apply.","solutions":["Fix the underlying deploy error reported after the '%w' suffix (it names the real cause)","Verify cluster connectivity: `kubectl cluster-info` and confirm the current context `kubectl config current-context`","Confirm the built images exist in the registry the cluster pulls from","Re-run `skaffold dev` once the deploy succeeds"],"exampleFix":"// before (skaffold.yaml deploy points at missing context)\ndeploy:\n  kubectl: {defaultNamespace: prod}\n// after (use an existing context/namespace)\ndeploy:\n  kubectl:\n    flags:\n      kubeconfig: /home/user/.kube/config\n    defaultNamespace: dev","handlingStrategy":"try-catch","validationCode":"// before running skaffold dev\nkubectl cluster-info && kubectl auth can-i create deployments --all-namespaces","typeGuard":"if strings.Contains(err.Error(), \"exiting dev mode because first deploy failed\") { /* inspect wrapped cause with errors.Unwrap */ }","tryCatchPattern":"if err := runSkaffoldDev(ctx); err != nil {\n    var deployErr error\n    if errors.Unwrap(err) != nil { deployErr = errors.Unwrap(err) }\n    log.Printf(\"first deploy failed: %v\", deployErr)\n    return fmt.Errorf(\"precheck your cluster/registry: %w\", deployErr)\n}","preventionTips":["Run `kubectl cluster-info` and `skaffold build` before `skaffold dev`","Pin a working kubeconfig context per project","Push/verify images exist in the registry the cluster can pull","Use `skaffold deploy` standalone to validate deploy config before dev"],"tags":["skaffold","deploy","dev-loop","kubernetes"],"backgroundTag":"first-deploy-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"}