{"record":{"id":"b23ba794c8ab4613","repo":"apache/shenyu","slug":"gateway-address-not-found-from-registry-b23ba7","errorCode":null,"errorMessage":"Gateway address not found from registry.","messagePattern":"Gateway address not found from registry\\.","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-sdk/shenyu-sdk-feign/src/main/java/org/apache/shenyu/sdk/feign/ShenyuDiscoveryClient.java","lineNumber":84,"sourceCode":"    }\n\n    /**\n     * Gets all ServiceInstances associated with a particular serviceId.\n     * @param serviceId The serviceId to query.\n     * @return A List of ServiceInstance.\n     */\n    public ServiceInstance getInstance(final String serviceId) {\n        final List<Upstream> upstreams;\n        if (Objects.isNull(registerRepository)) {\n            List<String> serverList = Arrays.asList(registerConfig.getServerLists().split(\",\"));\n            if (serverList.isEmpty()) {\n                throw new ShenyuException(\"illegal param, serverLists configuration required if registerType equals local.\");\n            }\n            upstreams = serverList.stream().map(serverAddress -> Upstream.builder().url(UriUtils.appendScheme(serverAddress, scheme)).build()).collect(Collectors.toList());\n        } else {\n            List<InstanceEntity> instanceRegisters = registerRepository.selectInstances(serviceId);\n            if (ObjectUtils.isEmpty(instanceRegisters)) {\n                throw new ShenyuException(\"Gateway address not found from registry.\");\n            }\n            upstreams = instanceRegisters.stream().map(instanceRegister -> {\n                final String instanceUrl = String.join(Constants.COLONS, instanceRegister.getHost(), Integer.toString(instanceRegister.getPort()));\n                return Upstream.builder().url(UriUtils.appendScheme(instanceUrl, scheme)).build();\n            }).collect(Collectors.toList());\n        }\n        // loadBalancer upstreams\n        if (CollectionUtils.isEmpty(upstreams)) {\n            LOG.error(\"The serviceId that named {} could not load balanced to at least one upstream.\", serviceId);\n        }\n        Upstream upstream = upstreams.get(0);\n        if (CollectionUtils.isNotEmpty(upstreams) && upstreams.size() > 1) {\n            upstream = LoadBalancerFactory.selector(upstreams, algorithm, new LoadBalanceData());\n        }\n\n        final URI uri = UriUtils.createUri(upstream.getUrl());\n        if (Objects.isNull(uri)) {\n            throw new ShenyuException(\"Gateway address uri is not invalid.\");","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-sdk/shenyu-sdk-feign/src/main/java/org/apache/shenyu/sdk/feign/ShenyuDiscoveryClient.java#L66-L102","documentation":"In registry mode (registerRepository is set), getInstance() looks up live gateway instances via registerRepository.selectInstances(serviceId). When the registry returns no instances the SDK cannot route the call and throws ShenyuException. This is a runtime discovery failure, unlike the static-mode config error.","triggerScenarios":"Calling getInstance(serviceId) where the registry (zookeeper/nacos/etcd/...) has no registered instances for that serviceId — wrong serviceId, gateway not yet registered, or gateway process down.","commonSituations":"Typo in the serviceId; gateway started after the SDK call; registry cluster unreachable so the repository cache is empty; instances deregistered after a session expiry; namespace/cluster mismatch between gateway and SDK.","solutions":["Confirm the gateway is running and registered: inspect the registry directly (e.g. zkCli ls /shenyu/instances) for the serviceId.","Check the serviceId string matches exactly what the gateway registers (case, prefix).","Verify SDK↔registry connectivity and credentials; fix connection errors so selectInstances returns data.","Add retry/fallback with backoff around instance lookup since registration can lag startup."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ServiceInstance inst = discoveryClient.getInstance(serviceId);\n} catch (ShenyuException e) {\n    // registry returned no instances: retry with backoff or fall back to a static address\n    retry(() -> discoveryClient.getInstance(serviceId), 3, Duration.ofSeconds(2));\n}","preventionTips":["Confirm the gateway is up and registered before starting dependent services.","Log the serviceId actually queried and compare it to what the gateway registers.","Monitor registry instance counts and alert when a known service drops to zero.","Add startup retry with backoff for early calls racing registration."],"tags":["service-discovery","registry","network"],"backgroundTag":"empty-result-set","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}