我刚买了一个亚马逊ec2实例并安装了erlang和elixir以及PostgreSQL。 只需放一个基本的凤凰应用程序。
当我运行混合phx。服务器 它从本地主机http://localhost:4000/
开始但我想在亚马逊公共IP中运行它。
So I put that in config/dev.exs
Http: [ip:{1, 2, 3, 4}, port:4000}
在此之后我创建了一个安全组并允许所有流量。
现在,当我使用sudo mix phx.server
启动应用程序时I am getting the below error
Compiling 10 files (.ex)
Generated myapp_test app
[error] Failed to start Ranch listener myappTestWeb.Endpoint.HTTP in :ranch_tcp:listen([port: 4000, ip: {1, 2, 3, 4}]) for reason :eaddrnotavail (can't assign requested address)
[info] Application myapp_test exited: myappTest.Application.start(:normal, []) returned an error: shutdown: failed to start child: myappTestWeb.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Handler
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, myappTestWeb.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, myappTestWeb.Endpoint.HTTP, :eaddrnotavail}
[info] Application phoenix_ecto exited: :stopped
[info] Application ecto exited: :stopped
[info] Application poolboy exited: :stopped
[info] Application postgrex exited: :stopped
[info] Application decimal exited: :stopped
[info] Application db_connection exited: :stopped
[info] Application connection exited: :stopped
[info] Application cowboy exited: :stopped
[info] Application cowlib exited: :stopped
[info] Application ranch exited: :stopped
[info] Application runtime_tools exited: :stopped
=INFO REPORT==== 23-Jan-2018::10:48:23 ===
application: logger
exited: stopped
type: temporary
** (Mix) Could not start application myapp_test: myappTest.Application.start(:normal, []) returned an error: shutdown: failed to start child: myappTestWeb.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Handler
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, myappTestWeb.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, myappTestWeb.Endpoint.HTTP, :eaddrnotavail}
当我将公共IP放入浏览器时,它也无法正常工作。 我是否需要安装apache或任何其他网络服务器。 要么 我是否需要在系统的任何地方绑定amazon公共IP?
我们将非常感谢您对如何解决问题的任何见解 谢谢
答案 0 :(得分:2)
此时你最好的选择是开始隔离失败的东西。一旦你能够识别出应该工作但不能工作的组件,你就能够更加专注地提问。一些故障排除方法可以帮助您入门:
ip address show
)?ping 8.8.8.8
)吗?sudo nc -l 80
(在ec2主机上)和机器上的nc <ec2-ip> 80
。然后你应该能够输入你的机器(确保你在一些角色后输入)并看到它出现在ec2主机上。