{"record":{"id":"bdcc78757999d1c8","repo":"hashicorp/nomad","slug":"service-address-mode-must-be-q-q-or-q-not-q","errorCode":null,"errorMessage":"Service address_mode must be %q, %q, or %q; not %q","messagePattern":"Service address_mode must be %q, %q, or %q; not %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":781,"sourceCode":"\n\t// Ensure the service name is valid per the below RFCs but make an exception\n\t// for our interpolation syntax by first stripping any environment variables from the name\n\n\tserviceNameStripped := args.ReplaceEnvWithPlaceHolder(s.Name, \"ENV-VAR\")\n\n\tif err := s.ValidateName(serviceNameStripped); err != nil {\n\t\t// Log actual service name, not the stripped version.\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"%v: %q\", err, s.Name))\n\t}\n\n\tswitch s.AddressMode {\n\tcase \"\", AddressModeAuto:\n\tcase AddressModeHost, AddressModeDriver, AddressModeAlloc, AddressModeAllocIPv6:\n\t\tif s.Address != \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Service address_mode must be %q if address is set\", AddressModeAuto))\n\t\t}\n\tdefault:\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Service address_mode must be %q, %q, or %q; not %q\", AddressModeAuto, AddressModeHost, AddressModeDriver, s.AddressMode))\n\t}\n\n\tswitch s.OnUpdate {\n\tcase \"\", OnUpdateIgnore, OnUpdateRequireHealthy, OnUpdateIgnoreWarn:\n\t\t// OK\n\tdefault:\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Service on_update must be %q, %q, or %q; not %q\", OnUpdateRequireHealthy, OnUpdateIgnoreWarn, OnUpdateIgnore, s.OnUpdate))\n\t}\n\n\t// Up until this point, all service validation has been independent of the\n\t// provider. From this point on, we have different validation paths. We can\n\t// also catch an incorrect provider parameter.\n\tswitch s.Provider {\n\tcase ServiceProviderConsul:\n\t\ts.validateConsulService(&mErr)\n\tcase ServiceProviderNomad:\n\t\ts.validateNomadService(&mErr)\n\tdefault:","sourceCodeStart":763,"sourceCodeEnd":799,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L763-L799","documentation":"In Service.Validate's AddressMode switch, the configured AddressMode fell into the default case, i.e. it was not one of the supported values (auto, host, driver, alloc, alloc_ipv6) — typically a typo in the jobspec address_mode field.","triggerScenarios":"Setting address_mode to an unrecognized value (typo like \"hosts\", \"bridge\", or old removed modes) on a service and validating it.","commonSituations":"Upgrading from old Nomad versions where different modes existed; typos; copying configs between Nomad and Consul template syntax.","solutions":["Use one of: auto, host, driver, alloc, alloc_ipv6","Omit address_mode entirely to use the default auto","Fix the typo in the mode string"],"exampleFix":"// before\naddress_mode = \"hosts\"\n// after\naddress_mode = \"host\"","handlingStrategy":"validation","validationCode":"var modes = []string{\"\",\"auto\",\"host\",\"driver\",\"alloc\",\"alloc-ipv6\"}\nif !slices.Contains(modes, s.AddressMode) {\n    return fmt.Errorf(\"invalid address_mode %q\", s.AddressMode)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy mode strings from Nomad docs, not memory","Check Nomad version compatibility for address_mode values"],"tags":["nomad","address-mode","validation"],"backgroundTag":"invalid-service-network-config","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"}