{"record":{"id":"899d9d7a888890dd","repo":"hashicorp/nomad","slug":"service-q-cannot-use-address-mode-alloc-ipv6-o","errorCode":null,"errorMessage":"service %q cannot use address_mode=\"alloc_ipv6\", only services defined in a \"group\" block can use this mode","messagePattern":"service %q cannot use address_mode=\"alloc_ipv6\", only services defined in a \"group\" block can use this mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":8490,"sourceCode":"\taddServicePort := func(label, service string) {\n\t\tif _, ok := servicePorts[label]; !ok {\n\t\t\tservicePorts[label] = map[string]struct{}{}\n\t\t}\n\t\tservicePorts[label][service] = struct{}{}\n\t}\n\tknownServices := make(map[string]struct{})\n\tfor i, service := range t.Services {\n\t\tif err := service.Validate(); err != nil {\n\t\t\touter := fmt.Errorf(\"service[%d] %+q validation failed: %s\", i, service.Name, err)\n\t\t\tmErr.Errors = append(mErr.Errors, outer)\n\t\t}\n\n\t\tif service.AddressMode == AddressModeAlloc {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"service %q cannot use address_mode=\\\"alloc\\\", only services defined in a \\\"group\\\" block can use this mode\", service.Name))\n\t\t}\n\n\t\tif service.AddressMode == AddressModeAllocIPv6 {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"service %q cannot use address_mode=\\\"alloc_ipv6\\\", only services defined in a \\\"group\\\" block can use this mode\", service.Name))\n\t\t}\n\n\t\t// Ensure that services with the same name are not being registered for\n\t\t// the same port\n\t\tif _, ok := knownServices[service.Name+service.PortLabel]; ok {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"service %q is duplicate\", service.Name))\n\t\t}\n\t\tknownServices[service.Name+service.PortLabel] = struct{}{}\n\n\t\tif service.PortLabel != \"\" {\n\t\t\tif service.AddressMode == \"driver\" {\n\t\t\t\t// Numeric port labels are valid for address_mode=driver\n\t\t\t\t_, err := strconv.Atoi(service.PortLabel)\n\t\t\t\tif err != nil {\n\t\t\t\t\t// Not a numeric port label, add it to list to check\n\t\t\t\t\taddServicePort(service.PortLabel, service.Name)\n\t\t\t\t}\n\t\t\t} else {","sourceCodeStart":8472,"sourceCodeEnd":8508,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L8472-L8508","documentation":"Same constraint as address_mode=\"alloc\" but for the IPv6 variant: address_mode=\"alloc_ipv6\" is only permitted on services declared directly in a \"group\" block. Task-level services cannot claim the allocation's IPv6 address because the address belongs to the allocation, not to an individual task's network namespace. Thrown during Job.Register validation and accumulated in the MultiError.","triggerScenarios":"Submitting a job where a service nested inside a `task` block sets `address_mode = \"alloc_ipv6\"` (AddressModeAllocIPv6).","commonSituations":"Configuring IPv6-only clusters and copy-pasting group service stanzas into tasks; experimenting with IPv6 address advertisement at the wrong nesting level.","solutions":["Move the service block from the `task` to the `group` level so alloc_ipv6 is legal.","Remove `address_mode = \"alloc_ipv6\"` from the task-level service and rely on the default driver mode.","Use `nomad job validate` locally to catch the misplacement before submitting."],"exampleFix":"// before\ntask \"app\" {\n  service {\n    name = \"svc6\"\n    address_mode = \"alloc_ipv6\"\n  }\n}\n\n// after\ngroup \"web\" {\n  service {\n    name = \"svc6\"\n    address_mode = \"alloc_ipv6\"\n  }\n  task \"app\" { }\n}","handlingStrategy":"validation","validationCode":"for _, tg := range job.TaskGroups {\n  for _, t := range tg.Tasks {\n    for _, s := range t.Services {\n      if s.AddressMode == \"alloc_ipv6\" {\n        return fmt.Errorf(\"service %q: move alloc_ipv6 to group level\", s.Name)\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep alloc_ipv6 services at group level only","Lint job files for address_mode usage inside task stanzas","Validate jobs with `nomad job validate` as a pre-submit gate"],"tags":["nomad","service-validation","ipv6","address-mode"],"backgroundTag":"invalid-service-address-mode","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"}