{"record":{"id":"02d5cd67f793470d","repo":"hashicorp/nomad","slug":"consul-gateway-bind-address-must-set-valid-port","errorCode":null,"errorMessage":"Consul Gateway Bind Address must set valid Port","messagePattern":"Consul Gateway Bind Address must set valid Port","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":2057,"sourceCode":"\t}\n\n\treturn &ConsulGatewayBindAddress{\n\t\tAddress: a.Address,\n\t\tPort:    a.Port,\n\t}\n}\n\nfunc (a *ConsulGatewayBindAddress) Validate() error {\n\tif a == nil {\n\t\treturn nil\n\t}\n\n\tif a.Address == \"\" {\n\t\treturn fmt.Errorf(\"Consul Gateway Bind Address must be set\")\n\t}\n\n\tif a.Port <= 0 && a.Port != -1 { // port -1 => nomad autofill\n\t\treturn fmt.Errorf(\"Consul Gateway Bind Address must set valid Port\")\n\t}\n\n\treturn nil\n}\n\n// ConsulGatewayProxy is used to tune parameters of the proxy instance acting as\n// one of the forms of Connect gateways that Consul supports.\n//\n// https://www.consul.io/docs/connect/proxies/envoy#gateway-options\ntype ConsulGatewayProxy struct {\n\tConnectTimeout                  *time.Duration\n\tEnvoyGatewayBindTaggedAddresses bool\n\tEnvoyGatewayBindAddresses       map[string]*ConsulGatewayBindAddress\n\tEnvoyGatewayNoDefaultBind       bool\n\tEnvoyDNSDiscoveryType           string\n\tConfig                          map[string]any\n}\n","sourceCodeStart":2039,"sourceCodeEnd":2075,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L2039-L2075","documentation":"ConsulGatewayBindAddress.Validate found a Port that is zero/negative and not the -1 sentinel. Port -1 tells Nomad to autofill (e.g. for dynamic ingress ports); any other non-positive value is rejected.","triggerScenarios":"Thrown at nomad/structs/services.go:2057 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set port to a positive value (1-65535)","Set port to -1 to let Nomad autofill the port"],"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"}