[error] Failed to start Ranch listener TrackerWeb.Endpoint.HTTP in :ranch_tcp:listen([cacerts: :..., key: :..., cert: :..., port: 4000]) for reason :eaddrinuse (address already in use)
** (Mix) Could not start application tracker: Tracker.Application.start(:normal, []) returned an error: shutdown: failed to start child: TrackerWeb.Endpoint
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, TrackerWeb.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, TrackerWeb.Endpoint.HTTP, :eaddrinuse}
It means you have another application running on port 4000. It can even be the same app, just in another tab.
I have been having the same issue recently.
sudo netstat -lp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4000 0.0.0.0:* LISTEN 21213/beam.smp
ps -e | grep beam
21213 pts/0 00:00:44 beam.smp
It’s “stuborn” to terminate, had to use:
kill -9 21213
ps -e | grep beam
[1]+ Killed iex -S mix phx.server
I also run this error in Windows. What i did is in cmd, i run
netstat -aon | findstr 4000
Then
taskkill /pid 5632 /f
With the number 5632 was the number after listening…
Then i run again
mix phx.server
And now the server is running