'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
Solution 1:[1]
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! :)
Solution 2:[2]
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!
Solution 3:[3]
In this case, go to:
- Run as -> Run configurations
- Environment
- Remove the port number 8080 from it and apply
- Try to run your application with different port by passing
server.port=8081in application.properties
Solution 4:[4]
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TYsewyn |
| Solution 2 | Shuai Wang |
| Solution 3 | ×¡×˜× ×œ×™ ×’×¨×•× ×Ÿ |
| Solution 4 | Andrea Girardi |
