Search code examples
spring-bootspring-cloudnetflix-eurekaspring-cloud-netflix

Spring Eureka looking for default port 8761 instead of custom port


I have a Spring Boot Eureka server app that is configured to run in port 5000 instead of the default one 8761. However when I run the SBA, I get some errors on the console related to java connection refused , while listening to localhost:8761

INFO 10408 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server ERROR 10408 --- [tbeatExecutor-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}

com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]

Later when I bring up the other microservices, I can see that they are getting registered in eureka running on port 5000 correctly. But why is the application ignoring the configuration while starting Eureka server at first?

Also as it evident from the picture embedded, the server is looking for registered and unavailable replicas in 8761.

Registered and Unavailable replicas look up at default port

Will highly appreciate any explanations on this.


Solution

  • Even after adding the registerWithEureka & fetchRegistry to false, it was still pointing to 8761 for replica url.

    eureka.client.registerWithEureka = false 
    eureka.client.fetchRegistry = false
    

    The root cause of the problem was not actually setting the self register/search registry properties to be false, but also to modify/specify the correct serviceUrl property.

    Added the following lines to the application.properties and now my Eureka server doesn't point to the default Eureka port of 8761 for registered replica url.

    eureka.client.serviceUrl.defaultZone: http://localhost:${server.port}/eureka/