Search code examples
microservicesnetflix-eurekanetflix-zuul

Trying to connect Eureka and Zuul and I have error


I'm trying to study microservices (and docker). Trying to connect Eureka and Zuul and I have error: "com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: eureka-service"

There's my zuul application.properties

spring.application.name=ZuulService
server.port=8080

eureka.client.service-url.defaultZone=http://eureka-service:9000/eureka
eureka.instance.prefer-ip-address=true

and eureka application.properties

spring.application.name=EurekaService
server.port=9000

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.wait-time-in-ms-when-sync-empty=0

Solution

  • java.net.UnknownHostException: eureka-service

    The eureka-service host cannot be resolved. This host is coming from

    eureka.client.service-url.defaultZone=http://eureka-service:9000/eureka
    

    of Zuul-service's application.properties. Give it the IP address of machine where your eureka-service is running. If it's on localhost, it would be:

    eureka.client.service-url.defaultZone=http://localhost:9000/eureka