简体   繁体   中英

Eureka always returns url with port 8080

Port 8080 is always returned from eureka no matter what configuration is in the client. Here is an example of my eureka configuration on the client:

This is the application.yml

eureka:
  client:
    register-with-eureka: true
    fetch-registry: false
    serviceUrl:
      defaultZone: http://eurekaserver.com/eureka
  instance:
    nonSecurePort: 80
    nonSecurePortEnabled: true
    hostname: myhost

The application using the above configuration will try to register with eureka. it can successfully register but eureka returns http://myhost.com:8080 . The expected url is suppose to be http://myhost.com .

The application runs on port 8080 however the restendpoint is reached by http://myhost.com . is there any way to fix this?

--Edit--

here is my bootstrap.yml

spring:
  application:
    name: myappname

In which file did you add this config? bootstrap.yml , application.yml , or a profile specific one? Also check for typos in the properties filename.

So what's happening is that your config isn't loaded properly. The auto-configuration of Eureka Client doesn't find an EurekaInstanceConfigBean in the current context, so it's creating one for you. By default it checks first server.port , then port and eventually it's setting the port to 8080 if previous keys haven't been set.

I didn't know which version you are using, but this has been the default behaviour for quite some time now.

I hope this helps! :)

I'm seeing the exact same behavior. All the clients registered with the server is returned with right url but wrong port number, 8080. I have 2 clients running on the same node with different name and port, the one is really using port 8080 is correctly showed on the eureka server but the one is using port 9090 is somehow also showing port 8080 on eureka server. I have tried to move the server.port to here and there (bootstrap.yml or application.yml) but there's no luck. Any help will be appreiated!

In this case, go to:

  1. Run as -> Run configurations
  2. Environment
  3. Remove the port number 8080 from it and apply
  4. Try to run your application with different port by passing server.port=8081 in application.properties

I had same issue and I have solved setting this parameter on application.properties:

server.port = 7011

It could be redundante (in my case, I get the port from Weblogic) but it is mandatory on Client configuration to avoid to register the service with default port (8080)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM