Epmd: Node Name Already Occupied

Hello, I’ve been struggling with an issue where I successfully deploy my release to my production webserver (Apache on Linux), but end up with an internal server error for visitors. In my syslog I see the following:

Jun 7 12:30:11 epmd: epmd: node name already occupied appName
Jun 7 12:30:11 run_erl[16481]: Erlang closed the connection.
Jun 7 12:31:34 appName[20514]: Starting up

Has anybody ran into this before? If so, how did you get past it? Thanks.

That just means a server was started up with the same name as an existing running server. My guess is starting up the new server while the old server is still running?

Sounds likely to me. I think the internal server errors that I’m getting must be either related to port forwarding or edeliver config values. Thanks!

I pulled some extra info from erlang.log (below)

I did manually kill all epmd processes. Do you have any ideas of other things I could check for? Thanks!

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:10] [hipe] [kernel-poll:false]

14:53:50.576 [error] Failed to start Ranch listener PhxGasWeb.Endpoint.HTTP in :ranch_tcp:listen([port: 4000]) for reason :eaddrinuse (address already in use)

14:53:50.581 [info] Application phxGas exited: PhxGas.Application.start(:normal, []) returned an error: shutdown: failed to start child: PhxGasWeb.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Handler
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, PhxGasWeb.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, PhxGasWeb.Endpoint.HTTP, :eaddrinuse}
{“Kernel pid terminated”,application_controller,"{application_start_failure,phxGas,{{shutdown,{failed_to_start_child,‘Elixir.PhxGasWeb.Endpoint’,{shutdown,{failed_to_start_child,‘Elixir.Phoenix.Endpoint.Handler’,{shutdown,{failed_to_start_child,{ranch_listener_sup,‘Elixir.PhxGasWeb.Endpoint.HTTP’},{shutdown,{failed_to_start_child,ranch_acceptors_sup,{listen_error,‘Elixir.PhxGasWeb.Endpoint.HTTP’,eaddrinuse}}}}}}}}},{‘Elixir.PhxGas.Application’,start,[normal,[]]}}}"}

Kernel pid terminated (application_controller) ({application_start_failure,phxGas,{{shutdown,{failed_to_start_child,‘Elixir.PhxGasWeb.Endpoint’,{shutdown,{failed_to_start_child,'Elixir.Phoenix.Endpoin

This tells you precisely the issue now, port 4000 is already in use, so check what process is running on that port. :slight_smile:

1 Like

I will investigate that. Thanks as always for your advice. I really appreciate your willingness to help!

1 Like

Hi, @OvermindDL1 .

I’ve been working through errors and feel like I’m starting to understand things a bit better, but I’ve been stuck with one error for most of today.

** (RuntimeError) server can’t start because :port in config is nil, please use a valid port number

I’ve read around quite a bit and see people recommending setting the port variable (most recently here: http://irclogger.com/.elixir-lang/2016-12-05) in the environment. I’ve tried setting it on my local machine and on my prod ubuntu server (~/.profile has “export PORT=4000”), but that hasn’t helped. I also manually set the port in prod.exs like this:

http: [port: {:system, “4000”}],
url: [host: “ablwptest.mccsc.edu”, port: {:system, “4000”}]

But, I still keep ending up with the port in config is nil error. So, there’s some fundamental flaw in my understanding. I’m getting this error when I attempt to populate my prod psql database. So, I’m trying to run MIX_ENV=prod mix run priv/repo/seeds.exs and I get port in config is nil.

So, I’ve worked through a lot of the postgresql errors and I feel like I’m maybe almost there, but can’t seem to get past this port issue. Do you have any suggestions? Thanks very much as always.

This means you are looking for an environment variable named "4000" to get the port number, since you have export PORT=4000 in your profile then you probably want {:system, "PORT"} instead? :slight_smile:

1 Like

Well, I’ve tried it both ways just looking for a way to get it working. I seem to get that error either way. I think one things that’s confusing me is the difference between ‘http’ and ‘url’. When I’ve used PORT in prod.exs, I’ve used it like this:

http: [port: {:system, “PORT”}],
url: [host: “subdomain.domain.edu”, port: {:system, “PORT”}],
server: true,
root: “.”,
version: Mix.Project.config[:version],
cache_static_manifest: “priv/static/cache_manifest.json”

Am I understanding that piece correctly?

That looks right, then of course you have to be setting the PORT environment variable at the time the server itself is started (not compiled).

1 Like

Ahh, I wonder if that’s the issue. Thanks for the tip!