LinuxJunior

Address already in use (port is taken)

A program can't bind its port because another process already listens on it. Use ss to find the owner, then stop it or move your service.

What you see

  • Address already in use when a server starts (the exact wording differs by program)

What it means

Only one process can listen on a given address and port. If something else already holds it, a second one cannot bind. Often it is an older copy of the same program.

How to confirm the cause

  1. 1
    Find the process listening on the port
    sudo ss -ltnp | grep ':8080'

    -l listening, -t TCP, -n numeric ports, -p show the owning process. Replace 8080 with your port. You need root to see processes you do not own.

Causes and fixes

  • An old instance of the same program is still running

    HOW TO TELL
    The process shown by ss is your own application.
    FIX
    Stop the old instance properly, then start the new one.
  • A different program uses that port

    HOW TO TELL
    ss shows a different process name.
    FIX
    Stop that program, or change the port in one of the two configurations.
  • A container publishes the port

    HOW TO TELL
    The owner is a container proxy or the runtime.
    FIX
    Find the container publishing it with docker ps, then stop or remap it.

How to stop it coming back

  • Let the service manager start and stop the program so duplicates are not left behind.
  • Keep a list of which service owns which port.

Keep going

Sources

Linux man-pages (man7.org) and the systemd manual (freedesktop.org), read 18 Nov 2026. Command options were checked against those pages.

Search

Search cheat sheets and projects