Error Codes Wiki

Linux Address Already in Use

Warningnetwork

About Linux Address Already in Use

Linux "Address already in use" (EADDRINUSE) means another process is already listening on the requested 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: errno 98 — bind() failed because port is occupied. Common when restarting services quickly. TIME_WAIT state can also block port reuse. Only one process can bind to a specific port. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Previous instance of the service still running. Another service using the same port. Port in TIME_WAIT state after recent connection. Zombie process 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: ss -tlnp | grep :port. Kill the process using the port: kill PID. Use SO_REUSEADDR socket option in your code. Wait for TIME_WAIT to expire (usually 60 seconds). 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 do I find what process is using the port?

Run: ss -tlnp | grep :80 or lsof -i :80 to see the process.

Overview

Linux "Address already in use" (EADDRINUSE) means another process is already listening on the requested port.

Key Details

  • errno 98 — bind() failed because port is occupied
  • Common when restarting services quickly
  • TIME_WAIT state can also block port reuse
  • Only one process can bind to a specific port

Common Causes

  • Previous instance of the service still running
  • Another service using the same port
  • Port in TIME_WAIT state after recent connection
  • Zombie process holding the port

Steps

  1. 1Find what is using the port: ss -tlnp | grep :port
  2. 2Kill the process using the port: kill PID
  3. 3Use SO_REUSEADDR socket option in your code
  4. 4Wait for TIME_WAIT to expire (usually 60 seconds)

Tags

linuxnetworkaddress already in usetroubleshootingfix

More in Network

Frequently Asked Questions

Run: ss -tlnp | grep :80 or lsof -i :80 to see the process.