Member-only story

How to find port conflicts within Linux system?

Siva
1 min readFeb 20, 2019

The below command helps in finding any open ports in Linux system.

$ lsof -i :4000COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 5513 defa 31u IPv4 176955 0t0 TCP *:4000 LISTEN)

I was trying to start a server running on port 4000,

$ mix phx.server

But somehow the below error kept coming, I used lsof to find the ports but it didn’t made any sense, It went blank.

[error] Failed to start Ranch listener PlatformWeb.Endpoint.HTTP in :ranch_tcp:listen([cacerts: :…, key: :…, cert: :…, port: 4000]) for reason :eaddrinuse (address already in use)

After bit of research, I found I kept open a vagrant box by port forwarding 4000 from guest box to the host machine.

Once I shutdown the vagrant box. It all came in place.

But still I’m yet find why I was not able to find the open ports in Ubuntu box. Maybe the answer lies in port forwarded rules? Maybe once I get enough time I will pursue solving it.

$ more Vagrantfile
config.vm.network "forwarded_port", guest: 4000, host: 4000, host_ip: "127.0.0
.1"

--

--

No responses yet