Phoenix app wont start after receiving this error```plain

[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.

4 Likes

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