{"record":{"id":"9e5bae67d62330ff","repo":"microsoft/garnet","slug":"invalid-endpoint-format-address-port","errorCode":null,"errorMessage":"Invalid endpoint format {Address} {Port}.","messagePattern":"Invalid endpoint format (.+?) (.+?)\\.","errorType":"validation","errorClass":"GarnetException","httpStatus":null,"severity":"critical","filePath":"libs/host/Configuration/Options.cs","lineNumber":766,"sourceCode":"                DeviceType = DeviceType.Native;\n            }\n\n            var deviceType = GetDeviceType(logger);\n\n            var useAzureStorage = deviceType == DeviceType.AzureStorage;\n            if (useAzureStorage && string.IsNullOrEmpty(AzureStorageConnectionString) && string.IsNullOrEmpty(AzureStorageServiceUri))\n                throw new InvalidAzureConfiguration(\"Cannot use AzureStorage device without supplying storage-string or storage-service-uri\");\n            if (useAzureStorage && !string.IsNullOrEmpty(AzureStorageConnectionString) && !string.IsNullOrEmpty(AzureStorageServiceUri))\n                throw new InvalidAzureConfiguration(\"Cannot use AzureStorage device with both storage-string and storage-service-uri\");\n\n            var logDir = LogDir;\n            if (!useAzureStorage && enableStorageTier) logDir = new DirectoryInfo(string.IsNullOrEmpty(logDir) ? \".\" : logDir).FullName;\n            var checkpointDir = CheckpointDir;\n            if (!useAzureStorage) checkpointDir = new DirectoryInfo(string.IsNullOrEmpty(checkpointDir) ? (string.IsNullOrEmpty(logDir) ? \".\" : logDir) : checkpointDir).FullName;\n\n            if (!Format.TryParseAddressList(Address, Port, out var endpoints, out _, ProtectedMode == CommandLineBooleanOption.True)\n              || endpoints.Length == 0)\n                throw new GarnetException($\"Invalid endpoint format {Address} {Port}.\");\n\n            EndPoint[] clusterAnnounceEndpoint = null;\n            if (ClusterAnnounceIp != null)\n            {\n                ClusterAnnouncePort = ClusterAnnouncePort == 0 ? Port : ClusterAnnouncePort;\n                clusterAnnounceEndpoint = Format.TryCreateEndpoint(ClusterAnnounceIp, ClusterAnnouncePort, tryConnect: false, logger: logger);\n                if (clusterAnnounceEndpoint == null || !endpoints.Any(endpoint =>\n                    endpoint is IPEndPoint listenEp && clusterAnnounceEndpoint[0] is IPEndPoint announceEp &&\n                    listenEp.Port == announceEp.Port &&\n                    (listenEp.Address.Equals(announceEp.Address) ||\n                     listenEp.Address.Equals(IPAddress.Any) ||\n                     listenEp.Address.Equals(IPAddress.IPv6Any))))\n                    throw new GarnetException(\"Cluster announce endpoint does not match list of listen endpoints provided!\");\n            }\n\n            if (!string.IsNullOrEmpty(UnixSocketPath))\n                endpoints = [.. endpoints, new UnixDomainSocketEndPoint(UnixSocketPath)];\n","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/Configuration/Options.cs#L748-L784","documentation":"GarnetException thrown during Options.Initialize when Format.TryParseAddressList fails to parse the Address/Port pair into at least one valid endpoint, or returns zero endpoints. This is the bind-address validation gate: the server cannot start without at least one valid listen endpoint. The error message echoes the raw Address and Port values for diagnostics.","triggerScenarios":"Setting --address or --port to a malformed or empty value; providing a port of 0 with no address; a hostname that cannot be parsed as an IP; a port string that is non-numeric; an IPv6 address missing brackets; ProtectedMode rejecting the address.","commonSituations":"Typo in the bind address (e.g., '127.0.0.O' instead of '127.0.0.1'); port set to a non-numeric or out-of-range value; copying a config across environments with a placeholder address; IPv6 address not wrapped in brackets in a combined address:port string.","solutions":["Check that --address is a valid IP literal (or '*'/empty for all interfaces) and --port is a numeric value in 1–65535.","For IPv6, ensure the address is bracketed, e.g., [::1]:6379.","If using ProtectedMode, verify the address is permitted under protected-mode rules.","Confirm the Address and Port fields are not swapped or empty in the config file."],"exampleFix":"// before\noptions.Address = \"127.0.0.O\";\noptions.Port = 6379;\n\n// after\noptions.Address = \"127.0.0.1\";\noptions.Port = 6379;","handlingStrategy":"validation","validationCode":"using System.Net;\n\nbool IsValidBindAddress(string address, int port)\n{\n    if (port < 1 || port > 65535) return false;\n    if (string.IsNullOrEmpty(address) || address == \"*\") return true;\n    return IPAddress.TryParse(address, out _);\n}\n\nvoid ValidateEndpoint(Options opts)\n{\n    if (!IsValidBindAddress(opts.Address, opts.Port))\n        throw new InvalidOperationException($\"Invalid endpoint: address='{opts.Address}' port={opts.Port}\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    options.Initialize(logger);\n}\ncatch (GarnetException ex) when (ex.Message.StartsWith(\"Invalid endpoint format\"))\n{\n    logger.LogCritical(\"Endpoint address/port is invalid: {Address}:{Port}\", options.Address, options.Port);\n    throw;\n}","preventionTips":["Validate address/port with IPAddress.TryParse and range checks before startup.","Use config templates with known-good endpoint defaults to avoid typos.","Bracket IPv6 addresses when combining address and port in a single string."],"tags":["config","endpoint","startup","address","port","validation","options"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}