Phoenix: A new Phoenix app (1.4.0.rc.1) does not start on Windows 10

Created on 21 Oct 2018  路  6Comments  路  Source: phoenixframework/phoenix

I installed Erlang/OTP 21.1, Elixir 1.7.3, Node.js 8.12.0 and PostgreSQL 11 on Windows 10, and created successfully a Phoenix app using phx.new version 1.4.0.rc.1.

When I started the server for the first time, I got following messages:

[warn] Phoenix is unable to create symlinks. Phoenix' code reloader will run considerably faster if symlinks are allowed. On Windows, the lack of symlinks may even cause empty assets to be served. Luckily, you can address this issue by starting your Windows terminal at least once with "Run as Administrator" and then running your Phoenix application.
[info] Application test_app exited: TestApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: TestAppWeb.Endpoint
** (EXIT) an exception was raised:
    ** (UndefinedFunctionError) function Plug.Cowboy.child_spec/1 is undefined (module Plug.Cowboy is not available)
        Plug.Cowboy.child_spec([scheme: :http, plug: {TestAppWeb.Endpoint, []}, options: [dispatch: [_: [{"/phoenix/live_reload/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {TestAppWeb.Endpoint, Phoenix.LiveReloader.Socket, [serializer: [{Phoenix.Socket.V1.JSONSerializer, "~>1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {TestAppWeb.Endpoint, TestAppWeb.UserSocket, [serializer: [{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {:_, Plug.Adapters.Cowboy.Handler, {TestAppWeb.Endpoint, []}}]], port: 4000, otp_app: :test_app]])
        (phoenix) lib/phoenix/endpoint/cowboy_adapter.ex:96: Phoenix.Endpoint.CowboyAdapter.child_spec/3
        (phoenix) lib/phoenix/endpoint/supervisor.ex:106: anonymous fn/6 inPhoenix.Endpoint.Supervisor.server_children/4
        (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
        (phoenix) lib/phoenix/endpoint/supervisor.ex:97: Phoenix.Endpoint.Supervisor.server_children/4
        (phoenix) lib/phoenix/endpoint/supervisor.ex:57: Phoenix.Endpoint.Supervisor.init/1
        (stdlib) supervisor.erl:295: :supervisor.init/1
        (stdlib) gen_server.erl:374: :gen_server.init_it/2
        (stdlib) gen_server.erl:342: :gen_server.init_it/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application test_app: TestApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: TestAppWeb.Endpoint
** (EXIT) an exception was raised:
    ** (UndefinedFunctionError) function Plug.Cowboy.child_spec/1 is undefined (module Plug.Cowboy is not available)
        Plug.Cowboy.child_spec([scheme: :http, plug: {TestAppWeb.Endpoint, []}, options: [dispatch: [_: [{"/phoenix/live_reload/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {TestAppWeb.Endpoint, Phoenix.LiveReloader.Socket, [serializer: [{Phoenix.Socket.V1.JSONSerializer, "~>1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {TestAppWeb.Endpoint, TestAppWeb.UserSocket, [serializer: [{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {:_, Plug.Adapters.Cowboy.Handler, {TestAppWeb.Endpoint, []}}]], port: 4000, otp_app: :test_app]])
        (phoenix) lib/phoenix/endpoint/cowboy_adapter.ex:96: Phoenix.Endpoint.CowboyAdapter.child_spec/3
        (phoenix) lib/phoenix/endpoint/supervisor.ex:106: anonymous fn/6 inPhoenix.Endpoint.Supervisor.server_children/4
        (elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
        (phoenix) lib/phoenix/endpoint/supervisor.ex:97: Phoenix.Endpoint.Supervisor.server_children/4
        (phoenix) lib/phoenix/endpoint/supervisor.ex:57: Phoenix.Endpoint.Supervisor.init/1
        (stdlib) supervisor.erl:295: :supervisor.init/1
        (stdlib) gen_server.erl:374: :gen_server.init_it/2
        (stdlib) gen_server.erl:342: :gen_server.init_it/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

According to the suggestion, I started my terminal once with "Run as Administrator" and ran my Phoenix app. The warning message have gone but I got the same error UndefinedFunctionError.

Most helpful comment

I encountered the Plug.Cowboy is not available error, too, though I'm on a mac. After a little searching, I was able to fix it by adding :plug_cowboy, "~> 2.0" to the dependencies, which also required upgrading cowboy).

All 6 comments

I encountered the Plug.Cowboy is not available error, too, though I'm on a mac. After a little searching, I was able to fix it by adding :plug_cowboy, "~> 2.0" to the dependencies, which also required upgrading cowboy).

Replace {:plug_cowboy, "~> 2.0"} to {:cowboy, "~> 1.0"} to the dependencies and reinstall.

You should be able to fix this by using phx.new 1.4.0.rc.2 which includes the changes required for plug 1.7

@prettyhandsome is correct.

Also, phoenix v1.4.0-rc.2 is out and it contains fixes for this. :)

@Gazler @josevalim

After recreating the app with phoenix 1.4.0-rc.2, I can start it without errors on Windows 10. Thanks a lot!

I had to add cowboy_plug to the applications list, otherwise I got the same error while starting a release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fertapric picture fertapric  路  3Comments

adamaiken89 picture adamaiken89  路  3Comments

thedanotto picture thedanotto  路  3Comments

josevalim picture josevalim  路  3Comments

tcoopman picture tcoopman  路  3Comments