com.sun.jersey.api.client.ClientHandlerException: Connection refused: connect in Spring Boot

The problem might be you have not specified the correct port for Eureka server. If you don't specify the port it will try to use default port 8080 which will lead to errors. Use configuration as mentioned below in your file. 8761 is default port for eureka server


Also make sure your annotate you main class as below

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class EurekaServerApplication {

    public static void main(String[] args) {, args);


Getting exception Connection refused . It means the server port number already running in background. Check your server port number running in background or not.

Follow this process:

May be running same port number in background, see and kill below commands in windows. Go to command prompt->Run below commands ,

Find open running ports:

C:\WINDOWS\system32>netstat -ano | findstr :Port number

Example: netstat -ano | findstr :8761

kill ports based on PID(process ID)

C:\WINDOWS\system32>taskkill /PID PIDNumber /F 

Example: taskkill /PID 3740 /F

Kill all running services using above commands and set port number and write below code in file.


#set port number

Just edit above lines. working fine.

Is EurekaServer running?

I had the same problem, the problem is I haven't running the Eureka Server. After running the Eureka Server it started working fine.