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:

  1. Incorrect Eureka Server Address in Client Configuration

    • Diagnosis: Check the eureka.client.serviceUrl.defaultZone property in your Eureka client’s application.properties or application.yml file. 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/
        
    • 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.
  2. 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.
  3. Firewall Blocking Eureka Server Port

    • Diagnosis: From the client machine (or where the client is running), try to telnet or nc to the Eureka server’s port. For example, if the server is on 192.168.1.100 and port 8761:
      telnet 192.168.1.100 8761
      
      If the connection is refused or times out, a firewall is likely blocking the port. Also, check the server’s host firewall (e.g., ufw on Ubuntu, firewalld on 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
        
    • 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.
  4. 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 the eureka.client.serviceUrl.defaultZone in the client’s configuration uses the correct IP address or hostname that is resolvable and reachable from the client. Use ping or nslookup from the client machine to test reachability of the Eureka server’s hostname/IP.
    • Fix: Update the eureka.client.serviceUrl.defaultZone to use the correct, resolvable address. For example, if the server is at 192.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.
  5. 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-eureka and eureka.client.fetch-registry. If these are set to false for 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, as true is the default).
      # For standalone Eureka server
      eureka.client.register-with-eureka=true
      eureka.client.fetch-registry=true
      
      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.
    • 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.
  6. 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 nslookup to 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.
  7. Misconfiguration of Eureka Server’s Own application.yml or application.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.hostname or eureka.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
        
    • Why it works: This ensures the Eureka server correctly advertises its own address, so clients can connect to it.

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.

Want structured learning?

Take the full Spring-boot course →