Spring cloud service discovery

39 Views Asked by At

eureka server

server:
    port: 8761
spring:
    application:
        name: EUREKA-SERVER
eureka:
    instance:
        hostname: eureka-server
        prefer-ip-address: true
    client:
        fetch-registry: false
        register-with-eureka: false
        serviceUrl:
            defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka

eureka-client

eureka:
  instance:
    hostname: eureka-server
    prefer-ip-address: true
  client:
    fetch-registry: true
    register-with-eureka: true
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${eureka.client.eureka-server-port}/eureka
    eureka-server-port: 8761

When I try to start eureka client i see below errors

2024-02-11T00:17:16.174+05:30  INFO 5228 --- [EUREKA_CLIENT] [  restartedMain] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2024-02-11T00:17:16.372+05:30 DEBUG 5228 --- [EUREKA_CLIENT] [  restartedMain] o.s.web.client.RestTemplate              : HTTP GET http://eureka-server:8090/eureka/apps/
2024-02-11T00:17:16.423+05:30 DEBUG 5228 --- [EUREKA_CLIENT] [  restartedMain] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2024-02-11T00:17:24.873+05:30  INFO 5228 --- [EUREKA_CLIENT] [  restartedMain] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://eureka-server:8090/eureka/}, exception=I/O error on GET request for "http://eureka-server:8090/eureka/apps/": No such host is known (eureka-server) stacktrace=org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://eureka-server:8090/eureka/apps/": No such host is known (eureka-server)
    at org.springframework.web.client.RestTemplate.createResourceAccessException(RestTemplate.java:905)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:885)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:781)

I tried to set ip address for server but that did not work. My expectation is I want to connect to eureka server with host name instead of http://localhost:8761 from local

0

There are 0 best solutions below