Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iex -S mix phoenix.server returns an ERROR. :bug #1355

Closed
DavidStrada opened this issue Nov 17, 2015 · 8 comments
Closed

iex -S mix phoenix.server returns an ERROR. :bug #1355

DavidStrada opened this issue Nov 17, 2015 · 8 comments

Comments

@DavidStrada
Copy link

When I fired the command iex -S mix phoenix.server i'm using your guide up and run ( http://www.phoenixframework.org/docs/up-and-running )[up and run] I got the following stack trace ( i believe this is an stack trace ), anyhow he's the info :

» iex -S mix phoenix.server
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]


=INFO REPORT==== 16-Nov-2015::17:43:07 ===
    application: logger
    exited: stopped
    type: temporary
** (Mix) Could not start application hello_phoenix: HelloPhoenix.start(:normal, []) returned an error: shutdown: failed to start child: HelloPhoenix.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
        ** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, HelloPhoenix.Endpoint.HTTP}
            ** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
                ** (EXIT) {:listen_error, HelloPhoenix.Endpoint.HTTP, :eaddrinuse}
@chrismccord
Copy link
Member

** (EXIT) {:listen_error, HelloPhoenix.Endpoint.HTTP, :eaddrinuse}

Your port is in use, but you should have received a printed error before the stack that told you so. Try a different port

@chrismccord
Copy link
Member

I just verified, you should have seen this logged:

[error] Running Chat.Endpoint with Cowboy on http://localhost:4000 failed, port already in use

Can you try again and report back on whether or not you see that error logged?

@DavidStrada
Copy link
Author

I'm quite new to elixir/phoenix how should i pass a port flag ? checked iex --help but couldn't find any.

@chrismccord
Copy link
Member

The default port is 4000, and it's set in config/dev.exs (or test.exs/prod.exs), but iex by default will use dev. So bump the port int your endpoint config in dev.exs and you should be all set. If you want to make it dynamic, you can use a PORT env var (like in prod.exs), i.e.:

http: [port: System.get_env("PORT") || 4000]

then PORT=4001 iex -S mix phoenix.server

@DavidStrada
Copy link
Author

When i used port=4001 it worked!, however using the dynamic port. http: [port: {:system, "PORT"}],

[error] Server can't start because :port in config is nil, please use a valid port number
[info] Application hello_phoenix exited: HelloPhoenix.start(:normal, []) returned an error: shutdown: failed to start child: HelloPhoenix.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
        ** (EXIT) shutdown

=INFO REPORT==== 16-Nov-2015::18:24:26 ===
    application: logger
    exited: stopped
    type: temporary
** (Mix) Could not start application hello_phoenix: HelloPhoenix.start(:normal, []) returned an error: shutdown: failed to start child: HelloPhoenix.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
        ** (EXIT) shutdown

@chrismccord
Copy link
Member

Perfect! It reports the error as expected: [error] Server can't start because :port in config is nil, please use a valid port number. Hop on elixir-lang irc if you have questions and welcome aboard!

@DavidStrada
Copy link
Author

Thanks 👍

@TimHeckel
Copy link

Alternatively, you can do: killall beam.smp to kill the phoenix server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants