Error Codes Wiki

Linux "Address Already in Use" — Port Conflict Fix

Warninglinux network

About Linux "Address Already in Use"

Fix "Address already in use" or "EADDRINUSE" error. Another process is using the port. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: Error: Address already in use (EADDRINUSE). Category: Linux Network Error. Port is occupied by another process. Service cannot start on desired port. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Another instance of the service is running. Previous process did not release the port. Different service using the same port. TIME_WAIT state holding the port. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Find what is using the port: sudo lsof -i :PORT. or: sudo ss -tlnp | grep PORT. Kill the process: sudo kill PID. Use SO_REUSEADDR in code for TIME_WAIT. Change to a different port if needed. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

How long does TIME_WAIT last?

Typically 60 seconds. Use SO_REUSEADDR to bind immediately.

Overview

Fix "Address already in use" or "EADDRINUSE" error. Another process is using the port.

Key Details

  • Error: Address already in use (EADDRINUSE)
  • Category: Linux Network Error
  • Port is occupied by another process
  • Service cannot start on desired port

Common Causes

  • Another instance of the service is running
  • Previous process did not release the port
  • Different service using the same port
  • TIME_WAIT state holding the port

Steps

  1. 1Find what is using the port: sudo lsof -i :PORT
  2. 2or: sudo ss -tlnp | grep PORT
  3. 3Kill the process: sudo kill PID
  4. 4Use SO_REUSEADDR in code for TIME_WAIT
  5. 5Change to a different port if needed

Tags

linuxlinux-networklinux port already in useubuntuterminal

More in Linux Network

Frequently Asked Questions

Typically 60 seconds. Use SO_REUSEADDR to bind immediately.