#rails

How to fix Address already in use?

Anonymous

AnonymousOct 03, 2023

Error: Address already in use - bind(2) for 127.0.0.1:3000 (Errno::EADDRINUSE)

This error message indicates that the port 3000 on the IP address 127.0.0.1 (localhost) is already in use by another process. To resolve this issue, you can follow these steps below:

Step 1: Find the process ID (PID)

lsof -wni tcp:<your port number>

example:

lsof -wni tcp:3000

The output will look something like this:

COMMAND     PID USER   FD   TYPE             DEVICE SIZE / OFF NODE NAME
ruby      28120 admin   13u  IPv4 0xcaa99f29c9960fd5      0t0  TCP 127.0.0.1: hbci(LISTEN)
ruby      28120 admin   14u  IPv6 0xcaa99f29c9960fd5      0t0  TCP[:: 1]: hbci(LISTEN)
ruby      28120 admin   13u  IPv4 0xcaa99f29c9960fd5      0t0  TCP 127.0.0.1: hbci(LISTEN)
ruby      28120 admin   14u  IPv6 0xcaa99f29c9960fd5      0t0  TCP[:: 1]: hbci(LISTEN)

Step 2: Then kill the process (where 28120 is the PID number)

kill -9 <your pid number>

example:

kill -9 28120