HTTPure + Heroku

hi there,

I am trying to build a RESTful API with HTTPure, and deploy it on Heroku, once everything is there on Heroku side, an error says

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

when I tried to visit the site, I am wondering if any of you have managed to deploy HTTPure app on Heroku? TIA

1 Like

I’ve had this issue with Heroku for other frameworks when I used localhost (127.0.0.1) instead of 0.0.0.0, which is required by Heroku.

For example, you want to see something like this in the logs:

app[web.1]: Web Server starting at http://0.0.0.0:37946
heroku[web.1]: State changed from starting to up

Not this:

app[web.1]: Web Server starting at http://127.0.0.1:39893
heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

hi @milesfrain, thank you for your answer. I reckon the default hostname the app is listening to is 0.0.0.0 https://github.com/cprussin/purescript-httpure/blob/master/src/HTTPure/Server.purs#L84, I didn’t change that.

Is your app written with HTTPure?

No, my only Heroku experience is with hosting a Genie.jl app, otherwise I would have shared a working HTTPure example.

Only other tips I can share are:

  • You need to grab the $PORT environment variable that heroku sets.
  • Adding some logging in your app to note the ip and port used would be helpful for troubleshooting.
1 Like

hi @milesfrain,

cheers, I will try to add more log :slight_smile:

I had issues setting up HTTPure on Heroku, was getting the same error

What fixed it for me was using serve' and explicitly setting the hostname to "0.0.0.0". This seems to have since been resolved in the master branch (these are the lines you linked to), but that change doesn’t appear to have made it into a release yet. Here’s a working example that I’ve successfully deployed to Heroku FWIW, in case this is the same issue you’re having: https://github.com/ptrfrncsmrph/purescript-httpure-example/blob/master/src/Main.purs.

2 Likes

hi @ptrfrncsmrph,

Cheers, I didn’t realise the realised version is using different hostname than the master branch :slight_smile:, I’ve changed my part to use servie' and it works now, cheers.

Regards
Hao

2 Likes