hashicorp/nomad · error
job %q is in nonexistent namespace %q
Error message
job %q is in nonexistent namespace %q
What it means
This job validator confirms the job's namespace actually exists in state store before applying namespace-scoped checks (drivers, network modes). If NamespaceByName returns nil, the job references a namespace that was never created, and registration is rejected with this error.
Source
Thrown at nomad/job_endpoint_validators.go:28
"github.com/hashicorp/nomad/nomad/structs"
)
type jobNamespaceConstraintCheckHook struct {
srv *Server
}
func (jobNamespaceConstraintCheckHook) Name() string {
return "namespace-constraint-check"
}
func (c jobNamespaceConstraintCheckHook) Validate(job *structs.Job) (warnings []error, err error) {
// This was validated before and matches the WriteRequest namespace
ns, err := c.srv.State().NamespaceByName(nil, job.Namespace)
if err != nil {
return nil, err
}
if ns == nil {
return nil, fmt.Errorf("job %q is in nonexistent namespace %q", job.ID, job.Namespace)
}
var disallowedDrivers []string
for _, tg := range job.TaskGroups {
for _, t := range tg.Tasks {
if !taskValidateDriver(t, ns) {
disallowedDrivers = append(disallowedDrivers, t.Driver)
}
}
}
if len(disallowedDrivers) > 0 {
if len(disallowedDrivers) == 1 {
return nil, fmt.Errorf(
"used task driver %q is not allowed in namespace %q", disallowedDrivers[0], ns.Name,
)
} else {
return nil, fmt.Errorf(View on GitHub (pinned to 482b49bf1a)
Solutions
- Create the namespace first: nomad namespace create <name> or via the namespaces API
- Correct the job's namespace field to an existing namespace
- Ensure infrastructure-as-code ordering: namespaces provisioned before job registration
Example fix
// before
job "web" { namespace = "payments" } // namespace missing
// after
nomad namespace create payments
// or set namespace = "default" Defensive patterns
Strategy: validation
Validate before calling
// before submit
ns, err := client.Namespaces().Info(job.Namespace, nil)
if err != nil || ns == nil {
return fmt.Errorf("create namespace %q first", job.Namespace)
} Prevention
- Provision namespaces as a prerequisite step in deployment pipelines
- Use a CI preflight that lists namespaces and cross-checks job specs
- Avoid hardcoding namespaces; source them from environment config
When it happens
Trigger: Submitting a job with namespace = "foo" when namespace "foo" has not been created. Raised in Validate (job_endpoint_validators.go) on every job register that passes through this hook.
Common situations: Job files copied between clusters where the target cluster lacks the namespace; namespace deleted while jobs referencing it are re-registered; typo in namespace name; CI deploys jobs before namespace bootstrap step runs.
Related errors
- used task driver %q is not allowed in namespace %q
- used task drivers %q are not allowed in namespace %q
- used group network mode %q is not allowed in namespace %q
- used group network modes %q are not allowed in namespace %q
- namespace not found
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/32750259f7a2c5c0.
Report an issue: GitHub.