Eureka replicas unavailable

10,022

I'm guessing your eurekas don't register themselves with localhost as their hostnames so this is why you're seeing them as unavailable in the eureka dashboards. Eureka uses this pattern a lot, it matches the service url with the caller hostname to determine replication context.

Peer eureka nodes are fetched in com.netflix.eureka.cluster.PeerEurekaNodes::resolvePeerUrls from the list of eureka service urls (eureka.client.serviceUrl key or DNS based). Later on, this list is matched against currently registered eureka applications in com.netflix.eureka.util.StatusUtil::getStatusInfo by using the hostname to get the replica statuses.

Since your application most likely doesn't register itself with localhost, it'll get added to the unavailable replicas.

Share:
10,022
Mont
Author by

Mont

Updated on June 04, 2022

Comments

  • Mont
    Mont almost 2 years

    I have problem with configuring eureka replicas :

    Eureka service :

    @EnableEurekaServer
    @SpringBootApplication
    public class DiscoveryService {
    
        public static void main(String[] args) {
            SpringApplication.run(DiscoveryService.class, args);
        }
    }
    

    bootstrap.properties

    spring.application.name=discovery
    spring.cloud.config.uri=http://localhost:8888
    

    I also have two yml files

    for server 1 runing on 8761

    eureka.client.serviceUrl.defaultZone:http://localhost:8762/eureka/
    eureka.client.registerWithEureka:false
    eureka.client.fetchRegistry:false
    

    for server 2 running on 8762

    eureka.client.serviceUrl.defaultZone:http://localhost:8761/eureka/
    eureka.client.registerWithEureka:false
    eureka.client.fetchRegistry:false
    

    I can enter both dashboards, but I see that both instance have this:

    registered-replicas http://localhost:8761/eureka/
    unavailable-replicas    http://localhost:8761/eureka/,
    available-replicas
    

    Why is that ?

  • Doug
    Doug about 6 years
    So you are saying we need to set eureka.instance.hostname=localhost ?
  • Doug
    Doug about 6 years
    I changed eureka.instance.hostname=peer0 to eureka.instance.hostname=machine_ip. I also had eureka.client.register-with-eureka set to false, so I had to change that to true. Now it works. thanks
  • jebeaudet
    jebeaudet about 6 years
    The hostname used in eureka.client.serviceUrl should match the one in eureka.instance.hostname for the eureka server.
  • Jef
    Jef about 3 years
    thanks, bro. I was struggling with this for a long time. Replaced my Host IP based configuration to hostname based and now it works like a charm.