hashicorp/nomad · error
Service %s is Connect Native and requires setting the task
Error message
Service %s is Connect Native and requires setting the task
What it means
When a service is Connect Native (connect { sidecar_service {} } with native via service registration flags — Connect.IsNative()), Nomad requires the `task` field on the service so the service can be attributed to and run within a specific task's namespace. If the task name is empty, validation fails. Normally job mutation fills this implicitly when there is only one task, so this error mostly appears in multi-task groups.
Source
Thrown at nomad/structs/services.go:895
case api.ServiceKindTypical,
api.ServiceKindAPIGateway,
api.ServiceKindIngressGateway,
api.ServiceKindMeshGateway,
api.ServiceKindTerminatingGateway:
default:
mErr.Errors = append(mErr.Errors, fmt.Errorf("Service %s kind must be one of consul service kind or empty", s.Name))
}
// check connect
if s.Connect != nil {
if err := s.Connect.Validate(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}
// if service is connect native, service task must be set (which may
// happen implicitly in a job mutation if there is only one task)
if s.Connect.IsNative() && len(s.TaskName) == 0 {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Service %s is Connect Native and requires setting the task", s.Name))
}
// if service is connect native a port must be set on the service or consul will reject it
if s.Connect.IsNative() && s.PortLabel == "" {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Service %s is Connect Native and requires setting the port", s.Name))
}
}
}
// validateNomadService performs validation on a service which is using the
// nomad provider.
func (s *Service) validateNomadService(mErr *multierror.Error) {
// check checks
for _, c := range s.Checks {
// validate the check port
if err := s.validateCheckPort(c); err != nil {
mErr.Errors = append(mErr.Errors, err)
continueView on GitHub (pinned to 482b49bf1a)
Solutions
- Add `task = "<task-name>"` to the service stanza naming the task that is Connect Native.
- Ensure the connect stanza is marked native (and the task binary actually supports Connect Native).
- If the service is not meant to be native, remove the native configuration so the sidecar path is used.
Example fix
// before
service {
name = "native-svc"
connect { sidecar_service {} }
}
// after
service {
name = "native-svc"
task = "app"
connect { sidecar_service {} }
} Defensive patterns
Strategy: validation
Validate before calling
if svc.Connect != nil && svc.Connect.IsNative() && svc.TaskName == "" {
return fmt.Errorf("connect-native service %q must set task", svc.Name)
} Prevention
- Always set `task` on service stanzas in multi-task groups
- Only mark services native when the app binary supports Connect Native
- Review group stanzas whenever the task count changes
When it happens
Trigger: A Connect Native service (Connect.IsNative() true) in a task group with multiple tasks where `task` is not set on the service stanza.
Common situations: Multi-task allocations with a Connect Native service; manually written jobs omitting the task field; jobs copied from single-task examples into multi-task groups.
Related errors
- Check %s invalid: tcp checks are not valid for Connect enabl
- Service %s is Connect Native and requires setting the port
- Consul Connect must be exclusively native, make use of a sid
- No Connect services in task group with Connect proxy (%q)
- Connect proxy service name (%q) not found in Connect service
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/39f1b2d69098483a.
Report an issue: GitHub.