← Back to Error Index
root@linuxfix:~/eaddrinuse$
EADDRINUSE
Address already in use

Solutions

Prerequisites: Start by updating your system to resolve common issues and ensure the solutions provided below are compatible with your current environment.
check_latest_version && sudo apt update && sudo apt upgrade -y
Find process using port

Identify what is using the port:

sudo netstat -tulpn | grep :port
sudo ss -tulpn | grep :port
sudo lsof -i :port
Kill process on port

Terminate the process using the port:

sudo kill -9 process_id
sudo pkill -f process_name
sudo fuser -k port/tcp
Use different port

Start service on alternative port:

service --port 8081
python -m http.server 8080
nginx -c config_with_different_port
Enable socket reuse

Configure socket options:

echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
sysctl net.ipv4.tcp_tw_reuse=1

What is EADDRINUSE?

EADDRINUSE occurs when trying to bind to a network address (IP:port) that is already in use.

Common scenarios: Starting servers on busy ports, multiple instances of same service, or ports in TIME_WAIT state.

Common Causes

  • Port already bound by another process
  • Previous connection in TIME_WAIT state
  • Multiple instances of same service
  • Socket not properly closed
  • Firewall or proxy using port

Debugging Tips

netstat -an | grep TIME_WAIT
ss -s
cat /proc/net/tcp
iptables -L -n

Prevention

  • Properly close sockets
  • Use unique ports for services
  • Configure socket reuse options
  • Monitor port usage
errno network socket port