Config server and eureka server in same application: tries to connect to localhost:8761
Solution 1
Could you try to change your configuration like below
eureka:
client:
registerWithEureka: false
fetchRegistry: false
service-url:
defaultZone: http://localhost:8888/eureka
You specify server.port: 8888
. So your eureka is running on 8888 port. But you didn't specify any service-url for eureka. So I think that your eureka server is trying to replicate to localhost:8761 because it's default and you didn't specify service-url for eureka.
Solution 2
Please Use 8761 port for your Eureka server as below.
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
Here we’re configuring an application port – 8761 is the default one for Eureka servers. We are telling the built-in Eureka Client not to register with ‘itself’, because our application should be acting as a server.
Solution 3
For me, below properties that worked for me.
eureka.client.registerWithEureka= false
eureka.client.fetchRegistry= false
eureka.server.maxThreadsForPeerReplication=0
Solution 4
It seems that eureka tries to connect to itself despite the below settings:
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
you have two options to fix that 1-Keep the default port of eureka 2-Add below to your application.properties
of your eureka server eureka.server.maxThreadsForPeerReplication=0
![meva](https://i.stack.imgur.com/m7FvQ.jpg?s=256&g=1)
meva
Updated on June 26, 2022Comments
-
meva about 2 years
I have a spring-boot application which I use to setup a
spring cloud config server
and aeureka server
in development and testing environments. Strangely the application always tries to connect tolocalhost:8761
, even though I haveeureka.client.registerWithEureka
set to false.How can I deactivate this?
The error:
ERROR 3144 --- [et_localhost-12] c.n.e.cluster.ReplicationTaskProcessor : Network level connection to peer localhost; retrying after delay com.sun.jersey.api.client.ClientHandlerException: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1] at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.4.10.jar:1.4.10] at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.4.10.jar:1.4.10] at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1] at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1] at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1] at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1] at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.4.10.jar:1.4.10] at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:71) ~[eureka-core-1.4.10.jar:1.4.10] at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.4.10.jar:1.4.10] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92] Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out
My only class looks like this:
@EnableEurekaServer @EnableConfigServer @SpringBootApplication public class MyApplication { public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); } }
The
application.yml
:server: port: 8888 eureka: client: registerWithEureka: false fetchRegistry: false server: waitTimeInMsWhenSyncEmpty: 0 renewal-percent-threshold: 0.49 security: basic: enabled: true user: password: mypassword spring: jmx: default-domain: ${spring.application.name} cloud: config: server: git: uri: https://example.com/myrepo.git username: username password: password clone-on-start: true search-paths: '{application},{application}/{profile}' endpoints: jmx: domain: ${spring.application.name} unique-names: true
In the
bootstrap.yml
I have only the application name set.Versions:
spring-cloud-netflix-eureka:
1.1.6
, spring-cloud-config-server:1.1.3