Menu
User

DropVPS Team

Writer: Cooper Reagan

How to Fix Port Already in Use Error on Linux

How to Fix Port Already in Use Error on Linux

Publication Date

12/31/2025

Category

Articles

Reading Time

2 Min

Table of Contents

The port already in use error happens when another process is already listening on the same port. This commonly affects web servers, Docker containers, and application services on a VPS.

Step 1: Identify the Process Using the Port

Find which process is currently bound to the port.

sudo ss -tulnp | grep :3000

Replace 3000 with the problematic port number.

Step 2: Get Process Details

Use lsof for clearer output.

sudo lsof -i :3000

Note the process name and PID.

Step 3: Stop the Service Gracefully

If the service is managed by systemd, stop it properly.

sudo systemctl stop service_name

Replace service_name with the actual service.

Step 4: Kill the Process Manually

If the service is not managed by systemd, terminate it using the PID.

sudo kill PID

Use the PID found in previous steps.

Step 5: Force Kill Stuck Processes

Only use this if the process refuses to stop.

sudo kill -9 PID

This immediately frees the port.

Step 6: Restart the Required Service

Once the port is free, restart your intended service.

sudo systemctl start service_name

Step 7: Prevent Future Port Conflicts

Avoid conflicts by checking ports before starting services.

sudo ss -tulnp

You may also want to review this related article: Block Suspicious Traffic on vps

Optional Step: Change the Service Port

If a port conflict happens frequently, changing the service port may be safer.

# Example for Node.js
PORT=4000 npm start
Linux VPS
U
Loading...

Related Posts