The Eureka client is failing to register with the Eureka server because the server is not responding to client requests at the expected network address.
Common Causes and Fixes:
-
Incorrect Eureka Server Address in Client Configuration
- Diagnosis: Check the
eureka.client.serviceUrl.defaultZoneproperty in your Eureka client’sapplication.propertiesorapplication.ymlfile. Ensure it matches the actual network address and port where your Eureka server is running and accessible. - Fix:
- application.properties:
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/ - application.yml:
eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/
- application.properties:
- Why it works: This property explicitly tells the client where to find the Eureka server for registration and discovery. If this URL is wrong, the client simply won’t know where to send its heartbeat or registration requests.
- Diagnosis: Check the
-
Eureka Server Not Running or Crashed
- Diagnosis: Attempt to access the Eureka server’s web UI directly in your browser at
http://localhost:8761/. If you get a connection refused or timeout error, the server is likely not running. Check the server’s application logs for startup errors or uncaught exceptions. - Fix: Ensure the Eureka server application is started. If it crashed, examine its logs for the root cause and resolve it. For example, if it’s a
OutOfMemoryError, you might need to increase the JVM heap size:java -Xmx1024m -jar eureka-server-0.0.1-SNAPSHOT.jar - Why it works: The Eureka server is the central registry. If it’s not running, no clients can register or discover anything.
- Diagnosis: Attempt to access the Eureka server’s web UI directly in your browser at
-
Firewall Blocking Eureka Server Port
- Diagnosis: From the client machine (or where the client is running), try to
telnetorncto the Eureka server’s port. For example, if the server is on192.168.1.100and port8761:
If the connection is refused or times out, a firewall is likely blocking the port. Also, check the server’s host firewall (e.g.,telnet 192.168.1.100 8761ufwon Ubuntu,firewalldon CentOS, or Windows Firewall). - Fix: Configure the firewall on the Eureka server’s host to allow inbound traffic on port
8761.- Ubuntu (ufw):
sudo ufw allow 8761/tcp sudo ufw reload - CentOS (firewalld):
sudo firewall-cmd --zone=public --add-port=8761/tcp --permanent sudo firewall-cmd --reload
- Ubuntu (ufw):
- Why it works: Network firewalls can prevent external connections to the server’s port, even if the application is running correctly. Opening the port allows the client to establish a connection.
- Diagnosis: From the client machine (or where the client is running), try to
-
Incorrect Eureka Server Hostname/IP in Client Configuration
- Diagnosis: If your Eureka server is not running on
localhost(e.g., it’s on a different machine or container), verify that theeureka.client.serviceUrl.defaultZonein the client’s configuration uses the correct IP address or hostname that is resolvable and reachable from the client. Usepingornslookupfrom the client machine to test reachability of the Eureka server’s hostname/IP. - Fix: Update the
eureka.client.serviceUrl.defaultZoneto use the correct, resolvable address. For example, if the server is at192.168.1.100:eureka.client.serviceUrl.defaultZone=http://192.168.1.100:8761/eureka/ - Why it works: DNS resolution or direct IP addressing failures prevent the client from locating the server on the network.
- Diagnosis: If your Eureka server is not running on
-
Eureka Server Not Registered with Itself (Self-Registration Issue)
- Diagnosis: When Eureka is run as a standalone server (not clustered), it needs to register itself with its own registry. This is controlled by
eureka.client.register-with-eurekaandeureka.client.fetch-registry. If these are set tofalsefor the server, it might not be available for clients. Check the Eureka server’s logs for messages indicating it’s failing to register or fetch its own registry. - Fix: Ensure that for a single Eureka server instance, these properties are set to
true(or not set, astrueis the default).
If you are running a cluster of Eureka servers, you would configure them to fetch from each other, but this property is crucial for a single instance to be discoverable.# For standalone Eureka server eureka.client.register-with-eureka=true eureka.client.fetch-registry=true - Why it works: The Eureka server needs to act as both a registry and a client to itself to be fully functional and visible to other clients.
- Diagnosis: When Eureka is run as a standalone server (not clustered), it needs to register itself with its own registry. This is controlled by
-
Network Issues or DNS Resolution Problems
- Diagnosis: Beyond firewalls and incorrect IPs, general network connectivity can be the culprit. From the client machine, try pinging the Eureka server’s IP address. If using hostnames, use
nslookupto ensure the hostname resolves to the correct IP. Check for any routing issues or network segmentation between the client and server. - Fix: Resolve underlying network problems, ensure DNS is configured correctly, or use static IP addresses if DNS is unreliable in your environment.
- Why it works: Fundamental network reachability is a prerequisite for any client-server communication.
- Diagnosis: Beyond firewalls and incorrect IPs, general network connectivity can be the culprit. From the client machine, try pinging the Eureka server’s IP address. If using hostnames, use
-
Misconfiguration of Eureka Server’s Own
application.ymlorapplication.properties- Diagnosis: The Eureka server itself needs to know its own network address if it’s not running on default ports or if it has multiple network interfaces. Look for properties like
eureka.instance.hostnameoreureka.instance.prefer-ip-address. If these are set incorrectly, the server might advertise a wrong address to clients. Check the server’s logs for messages about binding to an IP address. - Fix: Explicitly set the server’s hostname or IP address.
- application.properties (server):
eureka.instance.hostname=localhost # or if on a specific IP: # eureka.instance.hostname=192.168.1.100 # Or prefer IP over hostname: # eureka.instance.prefer-ip-address=true - application.yml (server):
eureka: instance: hostname: localhost # or # hostname: 192.168.1.100 # prefer-ip-address: true
- application.properties (server):
- Why it works: This ensures the Eureka server correctly advertises its own address, so clients can connect to it.
- Diagnosis: The Eureka server itself needs to know its own network address if it’s not running on default ports or if it has multiple network interfaces. Look for properties like
After fixing these issues, the next error you’ll likely encounter is a com.netflix.discovery.shared.transport.TransportException: Failed to connect to server if the server’s health checks are failing due to application-specific issues, or the client might try to register with a non-existent instance if the Eureka server itself is misconfigured to be unhealthy.