Fix “Address Already in Use” Error

How to find and stop the process that is already using a port on Linux.

By Rageypeep · Created 2026-03-04 11:37 UTC · Updated 2026-03-04 11:39 UTC

  • linux
  • networking
  • ports
  • troubleshooting
  • development

Fix "Address Already in Use" Error

What it means

This error happens when a program tries to bind to a port that another process is already using.

Example error:

OSError: [Errno 98] Address already in use

Step 1 — Find the process using the port

Example for port 5000:

lsof -i :5000

Example output:

python 1234 user TCP *:5000 (LISTEN)

Step 2 — Stop the process

Kill the process using the PID:

kill 1234

If it refuses to stop:

kill -9 1234

Alternative command

You can also use:

sudo fuser -k 5000/tcp

Notes

  • Very common when restarting web servers like Flask.
  • Make sure you are killing the correct process.

Score: 0

Comments

Loading comments...

View-only mode. Editing requires your private owner token.