{"record":{"id":"97906d26bdce6cff","repo":"hashicorp/nomad","slug":"failed-to-start-task-after-driver-exited-unexpecte","errorCode":null,"errorMessage":"failed to start task after driver exited unexpectedly: %v","messagePattern":"failed to start task after driver exited unexpectedly: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/task_runner.go","lineNumber":983,"sourceCode":"\t\t}\n\t\treturn nil\n\t}\n\n\t// Start the job if there's no existing handle (or if RecoverTask failed)\n\thandle, net, err := tr.driver.StartTask(taskConfig)\n\tif err != nil {\n\t\t// The plugin has died, try relaunching it\n\t\tif err == bstructs.ErrPluginShutdown {\n\t\t\ttr.logger.Info(\"failed to start task because plugin shutdown unexpectedly; attempting to recover\")\n\t\t\tif err := tr.initDriver(); err != nil {\n\t\t\t\ttaskErr := fmt.Errorf(\"failed to initialize driver after it exited unexpectedly: %v\", err)\n\t\t\t\ttr.EmitEvent(structs.NewTaskEvent(structs.TaskDriverFailure).SetDriverError(taskErr))\n\t\t\t\treturn taskErr\n\t\t\t}\n\n\t\t\thandle, net, err = tr.driver.StartTask(taskConfig)\n\t\t\tif err != nil {\n\t\t\t\ttaskErr := fmt.Errorf(\"failed to start task after driver exited unexpectedly: %v\", err)\n\t\t\t\ttr.EmitEvent(structs.NewTaskEvent(structs.TaskDriverFailure).SetDriverError(taskErr))\n\t\t\t\treturn taskErr\n\t\t\t}\n\t\t} else {\n\t\t\t// Do *NOT* wrap the error here without maintaining whether or not is Recoverable.\n\t\t\t// You must emit a task event failure to be considered Recoverable\n\t\t\ttr.EmitEvent(structs.NewTaskEvent(structs.TaskDriverFailure).SetDriverError(err))\n\t\t\treturn err\n\t\t}\n\t}\n\n\ttr.stateLock.Lock()\n\ttr.localState.TaskHandle = handle\n\ttr.localState.DriverNetwork = net\n\tif err := tr.stateDB.PutTaskRunnerLocalState(tr.allocID, tr.taskName, tr.localState); err != nil {\n\t\t//TODO Nomad will be unable to restore this task; try to kill\n\t\t//     it now and fail? In general we prefer to leave running\n\t\t//     tasks running even if the agent encounters an error.","sourceCodeStart":965,"sourceCodeEnd":1001,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/task_runner.go#L965-L1001","documentation":"In runDriver, after recovering from ErrPluginShutdown and successfully reinitializing the driver, the second StartTask attempt also failed; the task is marked TaskDriverFailure with this error and the run aborts.","triggerScenarios":"Thrown at client/allocrunner/taskrunner/task_runner.go:983 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the wrapped second StartTask error for the root cause","Check driver health and plugin logs after the reinit","Verify task config and host resources (ports, volumes) are valid","Reschedule the task on a healthy node/client"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}