{"record":{"id":"1a748f7ee433c1ac","repo":"go-delve/delve","slug":"cannot-restart-process-delve-did-not-create","errorCode":null,"errorMessage":"cannot restart process Delve did not create","messagePattern":"cannot restart process Delve did not create","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/rpc2/server.go","lineNumber":96,"sourceCode":"\n\t// When Rerecord is set the target will be rerecorded\n\tRerecord bool\n\n\t// When Rebuild is set the process will be build again\n\tRebuild bool\n\n\tNewRedirects [3]string\n}\n\ntype RestartOut struct {\n\tDiscardedBreakpoints []api.DiscardedBreakpoint\n}\n\n// Restart restarts program.\nfunc (s *RPCServer) Restart(arg RestartIn, cb service.RPCCallback) {\n\tclose(cb.SetupDoneChan())\n\tif s.config.Debugger.AttachPid != 0 {\n\t\tcb.Return(nil, errors.New(\"cannot restart process Delve did not create\"))\n\t\treturn\n\t}\n\tvar out RestartOut\n\tvar err error\n\tout.DiscardedBreakpoints, err = s.debugger.Restart(arg.Rerecord, arg.Position, arg.ResetArgs, arg.NewArgs, arg.NewRedirects, arg.Rebuild)\n\tcb.Return(out, err)\n}\n\ntype StateIn struct {\n\t// If NonBlocking is true State will return immediately even if the target process is running.\n\tNonBlocking bool\n}\n\ntype StateOut struct {\n\tState *api.DebuggerState\n}\n\n// State returns the current debugger state.","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/rpc2/server.go#L78-L114","documentation":"RPCServer.Restart refuses to restart a target process that Delve attached to rather than launched. Restart requires re-executing the program, which is only possible when Delve created the process itself; an attached (already-running) process cannot be relaunched.","triggerScenarios":"Calling the RPC Restart method (or 'restart' in a client) when the server was started with dlv attach, i.e. config.Debugger.AttachPid != 0.","commonSituations":"Developers debugging a running service via 'dlv attach <pid>' then issuing a restart command in the terminal or IDE expecting a re-launch.","solutions":["Detach and relaunch the program under 'dlv debug' or 'dlv exec' instead of attaching.","Exit the debug session, rebuild/restart the process, and attach to the new PID.","Use rerun workflows only for processes Delve launched.","Check AttachPid in your client before offering a restart option in the UI."],"exampleFix":"// before (client always shows restart)\ncall := svc.Restart(restartIn)\n// after\nif debuggerAttachPid == 0 {\n    call := svc.Restart(restartIn)\n} else {\n    fmt.Println(\"restart unavailable: attached to an existing process\")\n}","handlingStrategy":"validation","validationCode":"if attachPid != 0 {\n    return errors.New(\"restart not available for attached processes\")\n}","typeGuard":null,"tryCatchPattern":"var out rpc2.RestartOut\nerr := client.Call(\"RPCServer.Restart\", in, &out)\nif err != nil && strings.Contains(err.Error(), \"Delve did not create\") {\n    // fall back to relaunch workflow outside Delve\n}","preventionTips":["Track whether the session was launched (debug/exec/test) or attached.","Disable restart UI/actions when AttachPid != 0.","Document restart semantics for embedded Delve users."],"tags":["go","rpc","debugger","restart","attach"],"backgroundTag":"restart-attached-process-unsupported","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}