# How to Fix: EADDRINUSE, Address already in use - Kill server

The "EADDRINUSE, Address already in use" error occurs when you try to start a server on a port that is already in use by another process. To fix this issue, you can take the following steps:

## Identify the Process Holding the Port

You can use the following command to identify the process that is using the specific port:

```bash
lsof -i :<port_number>
```

Replace `<port_number>` with the actual port number where you are encountering the "EADDRINUSE" error. This command will show you the process ID (PID) and details of the process using that port.

## Kill the Process

Once you identify the PID of the process using the port, you can use the `kill` command to terminate that process. Replace `<PID>` with the actual process ID:

```bash
kill -9 <PID>
```

The `-9` option sends a SIGKILL signal to forcefully terminate the process.

## Restart Your Server

After killing the process, you should be able to restart your server without encountering the "EADDRINUSE" error.

### Example

Let's assume your server is running on port 3000, and you encounter the "EADDRINUSE" error:

```bash
lsof -i :3000
```

This will give you information about the process using port 3000. Let's say the PID is 1234:

```bash
kill -9 1234
```

Replace 1234 with the actual PID you obtained from the `lsof` command.

## Automated Approach (Unix-like Systems)

On Unix-like systems (Linux, macOS), you can combine these commands in a one-liner to quickly kill the process using the port:

```bash
lsof -i :<port_number> | awk 'NR!=1 {print $2}' | xargs kill -9
```

Replace `<port_number>` with your actual port number. This one-liner uses `awk` to extract the PID and `xargs` to pass it to the `kill` command.

After killing the process, you can restart your server on the specified port without encountering the "EADDRINUSE" error.