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

Error R10 -> Web process failed to bind to $PORT within 60 seconds of launch #73

Open
danielfoxp2 opened this issue Jan 20, 2018 · 10 comments

Comments

@danielfoxp2
Copy link

Hello guys!
I need serious help here, because I've already tried a lot - a very f lot - of things (including the #23 issue and others the google could find - different of him, my apps never works) to figure this out and got absolutely nothing. I don't even know if here is the right place to put it.

I am trying to deploy an app to heroku. I just create a regular phoenix 1.3 app and before start digging in my production code I like to make all the surrounds (db, acceptance tests, unit tests, deploy...) being ready. So there's almost nothing yet in my code besides what mix phx.new creates.

The few things I've changed was to prepare the app to be deployed to heroku. And I will show you what they are in a minute.

Following the phoenix guide on deploy to heroku I'm always ending up with this:

2018-01-20T13:38:30.289635+00:00 heroku[web.1]: State changed from crashed to starting
2018-01-20T13:38:36.199270+00:00 heroku[web.1]: Starting process with command `MIX_ENV=prod mix phx.server`
2018-01-20T13:39:36.561334+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-01-20T13:39:36.561424+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-01-20T13:39:36.674779+00:00 heroku[web.1]: Process exited with status 137
2018-01-20T13:39:36.689698+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-20T13:39:36.691037+00:00 heroku[web.1]: State changed from crashed to starting
2018-01-20T13:39:43.205253+00:00 heroku[web.1]: Starting process with command `MIX_ENV=prod mix phx.server`
2018-01-20T13:40:43.448578+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-01-20T13:40:43.448702+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-01-20T13:40:43.556983+00:00 heroku[web.1]: Process exited with status 137
2018-01-20T13:40:43.571869+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-20T13:40:45.543186+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=arcane-inlet-84609.herokuapp.com request_id=e4f881fc-714a-44dc-aa7d-1cda1bf3302d fwd="189.5.92.192" dyno= connect= service= status=503 bytes= protocol=https
2018-01-20T13:40:46.095610+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=arcane-inlet-84609.herokuapp.com request_id=73fd7237-8955-402a-9e4c-4935d2b69fcd fwd="189.5.92.192" dyno= connect= service= status=503 bytes= protocol=https

Sometimes, and I don't know why, I get a slightly different output:

2018-01-20T13:25:21.790935+00:00 heroku[web.1]: Starting process with command `MIX_ENV=prod mix phx.server`
2018-01-20T13:25:42.330456+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=arcane-inlet-84609.herokuapp.com request_id=97105890-900c-49fe-83db-2feab6552795 fwd="189.5.92.192" dyno= connect= service= status=503 bytes= protocol=https
2018-01-20T13:26:22.212939+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2018-01-20T13:26:22.281500+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-20T13:26:22.167596+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-01-20T13:26:22.167693+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-01-20T13:26:22.265385+00:00 heroku[web.1]: Process exited with status 22
2018-01-20T13:26:24.369615+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=arcane-inlet-84609.herokuapp.com request_id=005cb8e2-e13d-480b-b1c2-a0f968d38a4b fwd="189.5.92.192" dyno= connect= service= status=503 bytes= protocol=https
2018-01-20T13:26:24.960618+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=arcane-inlet-84609.herokuapp.com request_id=8bec1069-760a-471e-93a8-66a5dc297391 fwd="189.5.92.192" dyno= connect= service= status=503 bytes= protocol=https

I've tried (some of them was just to see if something changed, but no success):

  • Destroy and Create a new app;
  • Set config_vars_to_export;
  • Change Procfile MIX_ENV=prod mix phx.server to:
    • MIX_ENV=prod mix phoenix.server;
    • MIX_ENV=dev mix phx.server;
    • MIX_ENV=dev mix deps.get && mix phx.server
    • mix phx.server;
  • Set always_rebuild=true
  • Remove the elixir-buildpack.config and phoenix-static-buildpack.config¹ ;
  • Init another phoenix app unrelated with the first one;
  • Oh, the list goes on and on... I already forgot the most part of what I did till now;

I just can't figure out what is wrong.

My configuration is:

  • Docker container where elixir, phoenix, node and heroku-cli are installed;
  • Erlang 20.2.2
  • Elixir 1.6.0
  • Phoenix 1.3
  • Node 8.9.4
  • heroku-cli 6.15.17

The mix phx.server works just fine in localhost. That's why I chose here to present my really painful pain.

¹ I've create those *-buildpack.config to use the same version on heroku that my dev environment has - because I saw that the buildpacks works with older versions os erlang, elixir, phoenix, node... But this don't make difference because I removed those files and the error kept happening.

I, in advance, appreciate and thanks all of you who take the time to help.

@danielfoxp2
Copy link
Author

danielfoxp2 commented Jan 21, 2018

I made another container with older version of the environment.
Erlang = 19.0
Elixir = 1.4
Phoenix = 1.2
Node = 8.9.4

And in the same container that presents the issue I made an app with mix phoenix.new instead of mix phx.new, push both to keroku.

Both works without any problem. What am I missing???

@danielfoxp2
Copy link
Author

danielfoxp2 commented Jan 21, 2018

The problem seems to be with phoenix 1.3 command mix phx.new. I don't know why.
As I said above, I made a mix phoenix.new with elixir 1.6 in the same container that lead me to open the issue here and pushed to heroku and it works.

Then I create another container with older versions of everything (except node) and it works too.

But when I create the app with mix phx.new it just crash on heroku.

I don't know if is the buildpack or phoenix itself, @gjaldon, @chrismccord or anyone could please see if it is just with me?

@TiuTalk
Copy link

TiuTalk commented Apr 6, 2018

@danielfoxp2 did you manage to find a fix?

I could make it work by adding http: [port: {:system, "PORT"}] to my config/prod.exs like this:

config :dragon_slay, MyApp.Endpoint,
  http: [port: {:system, "PORT"}],
  load_from_system_env: true,
  url: [scheme: "https", host: "myapp.herokuapp.com", port: 443],
  force_ssl: [rewrite_on: [:x_forwarded_proto]],
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE")

@danielfoxp2
Copy link
Author

@TiuTalk, I didn't.

Because I made it work running with mix phoenix.new I gave up and now just use it like a phoenix 1.2. I don't remember if I've tried your approach. How did you find what caused the problem?

Next weekend I'll try in a new container what you described. If it works for me too it will be great, because my project now uses phoenix 1.3 with structure of 1.2. This is not good.

@richeterre
Copy link

richeterre commented Apr 27, 2018

I had a similar problem after migrating from Phoenix 1.2 to 1.3. Turned out I had forgotten to rename the endpoint module in prod.exs from MyApp.Endpoint to MyAppWeb.Endpoint, which caused the endpoint config to be ignored completely without a compiler warning. So whatever the underlying reason, make sure that your config can be correctly read by Heroku:

config :myapp, MyAppWeb.Endpoint,
  load_from_system_env: true,
  url: [scheme: "https", host: "www.myapp.com", port: 443],
  force_ssl: [rewrite_on: [:x_forwarded_proto]],
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE")

Remember to set the custom host if you're hosting the app under a custom domain. And lastly, make sure that your endpoint.ex contains an init/2 function as described in the docs. This might not solve your particular issue, but hopefully at least someone's who is as desperate as me when stumbling upon this issue 😄

@jomho
Copy link

jomho commented Nov 24, 2018

@TiuTalk Thank you for the solution.

If you are Heroku is logging:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launchl
and you are following the https://hexdocs.pm/phoenix/heroku.html tutorial, your fix is adding
http: [port: {:system, "PORT"}].

Seems obvious now, but ruined my last 6 hours.

elixir 1.7.4
phoenix 1.3.2
Erlang 21

@gil-air-may
Copy link

@jomho Great! You solved my problem :)

@edwinthinks
Copy link

@jomho thanks! I was punching my head over this for the past few hours. We ought to update that documentation to include this fix. https://github.com/phoenixframework/phoenix/blob/master/guides/deployment/heroku.md

@mayragss
Copy link

i soved this error using
app.listen(process.env.PORT || port,
process.env.PORT was the sulution

@idreesVenD
Copy link

@mayragss can you please elaborate where did you make the changes

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

8 participants