I want to register my micro services in Eureka with the IP address instead of host name.
I have tried both prefer-ip-address and eureka.instance.preferIpAddress=true properties. None of those worked for me.
Here is my eureka service application .yml file.
This is my Authorization-server micro-service application.yml
But still eureka console showing my services registered with host name(localhost) instead of IP address
I am using Spring boot 2.2.2 version and Spring cloud Hoxton.RELEASE. I am guessing the properties aren't working properly.
Is anyone experiencing the same problem?
Well I am on mobile so do not see everything clearly but seems like a problem In declaration
Correct syntax is
eureka.instance.preferIpAddress
Whereas you are using
eureka.instance.prefer-Ip-Address
See documentation: https://github.com/spring-cloud/spring-cloud-netflix/blob/a7398842078319dcaa353a708c12bb7b9fa85a4e/docs/src/main/asciidoc/spring-cloud-netflix.adoc#prefer-ip-address
eureka.instance.preferIpAddress=true will make instance register to Eureka server with IP address. You do not need to provide IP address in any configuration as that will be automatically picked up from system by the application.
In worst case scenario you can define specific IP address.
if you set either the eureka.instance.hostname or the eureka.instance.ipAddress those will always be used in the EurekaInstanceConfigBean so if those are not making it to the server in the registration we need to look at how it is used to build the InstanceInfo.