Caio Menezes
Caio Menezes

Reputation: 43

Spring Cloud Discrovery Eureka - Returns Localhost instead the hostname it is located

I am using Spring Cloud Eureka Server and Config Server, as Discovery First, and my problem is:

When a service registry it self in the eureka server the Config Server URL it returns is http://LOCALHOST:8888 intead of the http://{HOST_NAME}}:8888 and them all the other services hosted in another servers cannot find its configuration.

Log line:

Fetching config from server at: http://localhost:8888

Is there any configuration I can do to fix it?

The application.yml of configuration server is like that:

server:
  port: 8888

spring:
  application:
    name: configserver
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          searchLocations: /opt/config_dir

eureka:
  client:
    serviceUrl:
      defaultZone: http://10.111.22.33:8761/eureka,http://10.111.33.44:8761/eureka

The config client bootstrap.yml is like this:

spring:
  application:
    name: show-service
  profiles:
    active: dev
  cloud:
    discovery:
      enabled: true

eureka:
  client:
    serviceUrl:
      defaultZone: http://10.111.22.33:8761/eureka,http://10.111.33.44:8761/eureka

Upvotes: 0

Views: 1413

Answers (2)

Hanz
Hanz

Reputation: 264

i solved this issue by deploy my project
mvn deploy
hope this solve your problem

Upvotes: 0

nmyk
nmyk

Reputation: 1622

By default Discovery First Bootstrap is disabled. You are missing few properties in the config client application - to enable using discovery to look up the config server URL and your config server name (service-id).

spring:
  cloud:
    config:
      discovery:
       enabled: true
       service-id: configserver

More: https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_client.html#discovery-first-bootstrap

Upvotes: 2

Related Questions