{"record":{"id":"8f28715d9b3e8440","repo":"hashicorp/nomad","slug":"invalid-address-mode-q-s-only-valid-for-servic","errorCode":null,"errorMessage":"invalid address_mode %q - %s only valid for services","messagePattern":"invalid address_mode %q - (.+?) only valid for services","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":313,"sourceCode":"\t\treturn fmt.Errorf(\"timeout (%v) is lower than required minimum timeout %v\", sc.Timeout, minCheckInterval)\n\t}\n\n\t// validate the initial status\n\tswitch sc.InitialStatus {\n\tcase \"\":\n\tcase api.HealthPassing:\n\tcase api.HealthWarning:\n\tcase api.HealthCritical:\n\tdefault:\n\t\treturn fmt.Errorf(`invalid initial check state (%s), must be one of %q, %q, %q or empty`, sc.InitialStatus, api.HealthPassing, api.HealthWarning, api.HealthCritical)\n\t}\n\n\t// validate address_mode\n\tswitch sc.AddressMode {\n\tcase \"\", AddressModeHost, AddressModeDriver, AddressModeAlloc, AddressModeAllocIPv6:\n\t\t// Ok\n\tcase AddressModeAuto:\n\t\treturn fmt.Errorf(\"invalid address_mode %q - %s only valid for services\", sc.AddressMode, AddressModeAuto)\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid address_mode %q\", sc.AddressMode)\n\t}\n\n\t// validate on_update\n\tswitch sc.OnUpdate {\n\tcase \"\", OnUpdateIgnore, OnUpdateRequireHealthy, OnUpdateIgnoreWarn:\n\t\t// OK\n\tdefault:\n\t\treturn fmt.Errorf(\"on_update must be %q, %q, or %q; got %q\", OnUpdateRequireHealthy, OnUpdateIgnoreWarn, OnUpdateIgnore, sc.OnUpdate)\n\t}\n\n\t// validate check_restart and on_update do not conflict\n\tif sc.CheckRestart != nil {\n\t\t// CheckRestart and OnUpdate Ignore are incompatible If OnUpdate treats\n\t\t// an error has healthy, and the deployment succeeds followed by check\n\t\t// restart restarting failing checks, the deployment is left in an odd\n\t\t// state","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L295-L331","documentation":"Raised by ServiceCheck.validateCommon when a service check sets address_mode = \"auto\". The auto address mode is only valid on the service itself, not on individual checks; Nomad rejects it at check-validation time with a message clarifying that auto is service-only.","triggerScenarios":"A check block inside a service specifies address_mode = \"auto\" (e.g. check { address_mode = \"auto\" ... }); job submitted via nomad job run or jobs API.","commonSituations":"Assuming the service's address_mode value can be inherited or repeated on checks; copy-pasting the service-level address_mode into the check block; bridge-networking configs where auto seems natural.","solutions":["Remove address_mode from the check block so it inherits the service's address mode","Use \"host\" or \"driver\" explicitly on the check instead of \"auto\"","If you need auto resolution, set address_mode = \"auto\" on the parent service only","Run nomad job validate before submitting"],"exampleFix":"// before\nservice {\n  name = \"web\"\n  check {\n    address_mode = \"auto\"\n    type         = \"http\"\n    path         = \"/health\"\n  }\n}\n// after\nservice {\n  name         = \"web\"\n  address_mode = \"auto\"\n  check {\n    type = \"http\"\n    path = \"/health\"\n  }\n}","handlingStrategy":"validation","validationCode":"// Go: reject address_mode=\"auto\" on checks before submission\nif check.AddressMode == structs.AddressModeAuto {\n\treturn fmt.Errorf(\"address_mode auto is only valid on services, not checks\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never copy address_mode from the service block into its checks","Set address_mode at the service level and let checks inherit","Use only \"host\" or \"driver\" explicitly on checks","Run `nomad job validate` before submission"],"tags":["nomad","service-check","address-mode","config-validation"],"backgroundTag":"invalid-enum-value","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"}