{"record":{"id":"771a13cc0421ed1f","repo":"hashicorp/nomad","slug":"cannot-use-custom-advertise-address-with-q-addres","errorCode":null,"errorMessage":"cannot use custom advertise address with %q address mode","messagePattern":"cannot use custom advertise address with %q address mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/serviceregistration/address.go","lineNumber":55,"sourceCode":"\t\t\t// the group network address is DIY. (e.g. EC2 public address)\n\t\t\tif mapping, exists := ports.Get(portLabel); exists {\n\t\t\t\treturn address, mapping.Value, nil\n\t\t\t}\n\t\t\t// If not a port map we can interpolate a numeric port for you.\n\t\t\tport, err := strconv.Atoi(portLabel)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", 0, fmt.Errorf(\"invalid port: %q: not a valid port mapping or numeric port\", portLabel)\n\t\t\t}\n\t\t\treturn address, port, nil\n\t\tcase driverNet.Advertise():\n\t\t\treturn GetAddress(\"\", structs.AddressModeDriver, portLabel, networks, driverNet, ports, netStatus)\n\t\tdefault:\n\t\t\treturn GetAddress(\"\", structs.AddressModeHost, portLabel, networks, driverNet, ports, netStatus)\n\t\t}\n\tcase structs.AddressModeHost:\n\t\t// Cannot use address mode host with custom advertise address.\n\t\tif address != \"\" {\n\t\t\treturn \"\", 0, fmt.Errorf(\"cannot use custom advertise address with %q address mode\", structs.AddressModeHost)\n\t\t}\n\n\t\tif portLabel == \"\" {\n\t\t\tif len(networks) != 1 {\n\t\t\t\t// If no networks are specified return zero\n\t\t\t\t// values. Consul will advertise the host IP\n\t\t\t\t// with no port. This is the pre-0.7.1 behavior\n\t\t\t\t// some people rely on.\n\t\t\t\treturn \"\", 0, nil\n\t\t\t}\n\t\t\treturn networks[0].IP, 0, nil\n\t\t}\n\n\t\t// Default path: use host ip:port\n\t\t// Try finding port in the AllocatedPorts struct first\n\t\t// Check in Networks struct for backwards compatibility if not found\n\t\tmapping, ok := ports.Get(portLabel)\n\t\tif !ok {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/serviceregistration/address.go#L37-L73","documentation":"GetAddress rejects combining a custom advertise address with AddressModeDriver: an explicit address was given while address_mode=driver, which requires using the driver-assigned network IP, so the request is invalid and fails registration address resolution.","triggerScenarios":"Thrown at client/serviceregistration/address.go:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the explicit address when using address_mode=\"driver\"","Use address_mode=\"host\" or \"auto\" if a custom advertise address is required"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}