{"record":{"id":"c294fd03d35df954","repo":"hyperledger/fabric","slug":"s-is-not-a-valid-port-number","errorCode":null,"errorMessage":"%s is not a valid port number","messagePattern":"(.+?) is not a valid port number","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/support/config/support.go","lineNumber":192,"sourceCode":"\t\t}\n\t}\n\n\treturn res, nil\n}\n\nfunc globalEndpoints(endpointsByMSPID map[string][]string, ordererAddresses []string) (map[string]*discovery.Endpoints, error) {\n\tres := make(map[string]*discovery.Endpoints)\n\n\tfor mspID := range endpointsByMSPID {\n\t\tres[mspID] = &discovery.Endpoints{}\n\t\tfor _, endpoint := range ordererAddresses {\n\t\t\thost, portStr, err := net.SplitHostPort(endpoint)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Errorf(\"failed parsing orderer endpoint %s\", endpoint)\n\t\t\t}\n\t\t\tport, err := strconv.ParseInt(portStr, 10, 32)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Errorf(\"%s is not a valid port number\", portStr)\n\t\t\t}\n\t\t\tres[mspID].Endpoint = append(res[mspID].Endpoint, &discovery.Endpoint{\n\t\t\t\tHost: host,\n\t\t\t\tPort: uint32(port),\n\t\t\t})\n\t\t}\n\t}\n\treturn res, nil\n}\n\nfunc appendMSPConfigs(ordererGrp, appGrp map[string]*common.ConfigGroup, output map[string]*msp.FabricMSPConfig) error {\n\tfor _, group := range []map[string]*common.ConfigGroup{ordererGrp, appGrp} {\n\t\tfor _, grp := range group {\n\t\t\tmspConfig := &msp.MSPConfig{}\n\t\t\tif err := proto.Unmarshal(grp.Values[channelconfig.MSPKey].Value, mspConfig); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed parsing MSPConfig\")\n\t\t\t}\n\t\t\t// Skip non fabric MSPs, as they don't carry useful information for service discovery","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/support/config/support.go#L174-L210","documentation":"This error means the port portion of a global orderer endpoint parsed by net.SplitHostPort is not a valid integer in the int32 range, so it cannot be converted to the uint32 port of a discovery.Endpoint. Like the parse failure of the full endpoint, this aborts the entire globalEndpoints computation. The message contains the offending port substring.","triggerScenarios":"In globalEndpoints, after a successful host:port split, strconv.ParseInt(portStr, 10, 32) fails because portStr is non-numeric (e.g. 'orderer.example.com:http', '7o50'), empty (address ended with ':'), or numerically out of range.","commonSituations":"Named service ports ('orderer:grpc') instead of numeric ports in OrdererAddresses; truncated addresses like 'host:'; typos in configtx.yaml; template variables not substituted leaving placeholders in the port position.","solutions":["Replace the non-numeric or out-of-range port with a valid numeric port (1-65535) in the orderer addresses.","Regenerate/update the channel configuration via configtxgen/configtxlator after fixing.","Pre-validate endpoints by splitting and parsing the port before config submission.","Check for unresolved template/env placeholders or truncated ':' values in the config source."],"exampleFix":"// before\nOrdererAddresses:\n  - orderer.example.com:grpc\n// after\nOrdererAddresses:\n  - orderer.example.com:7050","handlingStrategy":"validation","validationCode":"func validatePorts(addrs []string) error {\n    for _, a := range addrs {\n        _, portStr, err := net.SplitHostPort(a)\n        if err != nil {\n            return err\n        }\n        if _, err := strconv.ParseInt(portStr, 10, 32); err != nil {\n            return fmt.Errorf(\"address %q has invalid port %q\", a, portStr)\n        }\n    }\n    return nil\n}","typeGuard":"func hasValidPort(s string) bool {\n    _, portStr, err := net.SplitHostPort(s)\n    if err != nil {\n        return false\n    }\n    p, err := strconv.ParseInt(portStr, 10, 32)\n    return err == nil && p > 0 && p <= 65535\n}","tryCatchPattern":"eps, err := support.OrdererEndpoints()\nif err != nil {\n    if strings.Contains(err.Error(), \"not a valid port number\") {\n        // surface a config-validation message pointing at the offending port\n    }\n    return err\n}","preventionTips":["Use numeric ports only; never named services or placeholders in orderer addresses.","Never leave an address ending in ':' without a port.","Range-check ports (1-65535) when templating config from env variables.","Validate all OrdererAddresses entries with strconv before submitting config updates."],"tags":["network","hyperledger-fabric","config","endpoints"],"backgroundTag":"invalid-port-number","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}