{"record":{"id":"ece6d73d22b1aa31","repo":"hashicorp/nomad","slug":"hostname-is-not-a-valid-dns-name","errorCode":null,"errorMessage":"Hostname is not a valid DNS name","messagePattern":"Hostname is not a valid DNS name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7411,"sourceCode":"\t\t\t\t// a job that will most likely error later on the client anyway.\n\t\t\t\tif strings.Contains(k, \";\") {\n\t\t\t\t\terr := fmt.Errorf(\"invalid ';' character in CNI arg key %q\", k)\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t\t}\n\t\t\t\tif strings.Contains(v, \";\") {\n\t\t\t\t\terr := fmt.Errorf(\"invalid ';' character in CNI arg value %q\", v)\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Validate the hostname field to be a valid DNS name. If the parameter\n\t\t// looks like it includes an interpolation value, we skip this. It\n\t\t// would be nice to validate additional parameters, but this isn't the\n\t\t// right place.\n\t\tif net.Hostname != \"\" && !strings.Contains(net.Hostname, \"${\") {\n\t\t\tif _, ok := dns.IsDomainName(net.Hostname); !ok {\n\t\t\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Hostname is not a valid DNS name\"))\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check for duplicate tasks or port labels, and no duplicated static ports\n\tfor _, task := range tg.Tasks {\n\t\tif task.Resources == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, net := range task.Resources.Networks {\n\t\t\tfor _, port := range append(net.ReservedPorts, net.DynamicPorts...) {\n\t\t\t\tif other, ok := portLabels[port.Label]; ok {\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Port label %s already in use by %s\", port.Label, other))\n\t\t\t\t}\n\n\t\t\t\tif port.Value != 0 {\n\t\t\t\t\thostNetwork := port.HostNetwork","sourceCodeStart":7393,"sourceCodeEnd":7429,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7393-L7429","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nservice { name = \"api\"  provider = \"nomad\" }\nservice { name = \"metrics\" provider = \"consul\" }\n// after\nservice { name = \"api\"  provider = \"nomad\" }\nservice { name = \"metrics\" provider = \"nomad\" }","handlingStrategy":"validation","validationCode":"providers := map[string]bool{}\nfor _, s := range append(tg.Services, taskServices...) {\n    p := s.Provider; if p == \"\" { p = \"consul\" }\n    providers[p] = true\n}\nif len(providers) > 1 { return errors.New(\"all services in a group must use the same provider\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on one service provider per group","Set provider explicitly on every service block","Review new service blocks copied from docs for provider mismatch"],"tags":["nomad","service-discovery","config-validation"],"backgroundTag":"conflicting-config-options","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"}