hashicorp/nomad · error
Hostname is not a valid DNS name
Error message
Hostname is not a valid DNS name
What it means
All services within a single task group must use the same service provider (consul or nomad). Nomad's native service discovery initially requires one provider per group, so mixing providers across group services appends this error during TaskGroup validation.
Source
Thrown at nomad/structs/structs.go:7411
// a job that will most likely error later on the client anyway.
if strings.Contains(k, ";") {
err := fmt.Errorf("invalid ';' character in CNI arg key %q", k)
mErr.Errors = append(mErr.Errors, err)
}
if strings.Contains(v, ";") {
err := fmt.Errorf("invalid ';' character in CNI arg value %q", v)
mErr.Errors = append(mErr.Errors, err)
}
}
}
// Validate the hostname field to be a valid DNS name. If the parameter
// looks like it includes an interpolation value, we skip this. It
// would be nice to validate additional parameters, but this isn't the
// right place.
if net.Hostname != "" && !strings.Contains(net.Hostname, "${") {
if _, ok := dns.IsDomainName(net.Hostname); !ok {
mErr.Errors = append(mErr.Errors, errors.New("Hostname is not a valid DNS name"))
}
}
}
// Check for duplicate tasks or port labels, and no duplicated static ports
for _, task := range tg.Tasks {
if task.Resources == nil {
continue
}
for _, net := range task.Resources.Networks {
for _, port := range append(net.ReservedPorts, net.DynamicPorts...) {
if other, ok := portLabels[port.Label]; ok {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Port label %s already in use by %s", port.Label, other))
}
if port.Value != 0 {
hostNetwork := port.HostNetworkView on GitHub (pinned to 482b49bf1a)
Solutions
- Set the same provider on every service block in the group.
- Omit provider on all services so they default to the same value.
- Split services into different task groups if they must use different providers.
Example fix
// before
service { name = "api" provider = "nomad" }
service { name = "metrics" provider = "consul" }
// after
service { name = "api" provider = "nomad" }
service { name = "metrics" provider = "nomad" } Defensive patterns
Strategy: validation
Validate before calling
providers := map[string]bool{}
for _, s := range append(tg.Services, taskServices...) {
p := s.Provider; if p == "" { p = "consul" }
providers[p] = true
}
if len(providers) > 1 { return errors.New("all services in a group must use the same provider") } Prevention
- Standardize on one service provider per group
- Set provider explicitly on every service block
- Review new service blocks copied from docs for provider mismatch
When it happens
Trigger: Submitting a job where one group-level or task-level service block sets provider = "nomad" while another service in the same group uses provider = "consul" (or omits provider, defaulting to consul).
Common situations: Adding a new service block that copies an example using the other provider; gradually migrating services from Consul to Nomad discovery one block at a time within one group.
Related errors
- failed to parse config:
- only one of cgroups_v1_override and cgroups_v2_override may
- work_dir must be an absolute path
- require only one of PemKey or PemKeyFile
- missing PemCert, PemCertFile, or KeyID
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/ece6d73d22b1aa31.
Report an issue: GitHub.