1

I have been struggling to get my app loaded to heroku for the past couple of days. I get over one hurdle and then meet another. Now I am getting a the following error.

 Failed to load resource: the server responded with a status of 503 (Service  Unavailable) /favicon.ico

On the logs I am getting these error messages.

2018-04-11T08:13:48.238214+00:00 app[web.1]: > rock-paper-scissors@1.0.0 start  /app
2018-04-11T08:13:48.331598+00:00 app[web.1]: Server has started.
2018-04-11T08:13:48.238216+00:00 app[web.1]: 
2018-04-11T08:13:48.238198+00:00 app[web.1]: 
2018-04-11T08:14:46.646952+00:00 heroku[web.1]: State changed from starting to   crashed
2018-04-11T08:14:46.571274+00:00 heroku[web.1]: Error R10 (Boot timeout) ->    Web process failed to bind to $PORT within 60 seconds of launch
2018-04-11T08:14:46.629369+00:00 heroku[web.1]: Process exited with status 137
2018-04-11T09:38:48.218885+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=brianpat-rock-paper-scissors.herokuapp.com request_id=0db40b3c-c918-4a3d-9a4d-f3a5fcf69bc8 fwd="94.174.32.117" dyno= connect= service= status=503 bytes= protocol=https
2018-04-11T09:38:48.541351+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=brianpat-rock-paper-scissors.herokuapp.com request_id=ecf56ae7-84e6-43a0-9a77-3e9f9a7f538f fwd="94.174.32.117" dyno= connect= service= status=503 bytes= protocol=https

Yesterday I was getting a Method not Allowed error and now I am not sure if it has moved on or not. Not sure if this is my end or whether this is a maintenance issue with heroku? Possibly my end. I have tried looking for the same error on Stackoverflow but they have not proved helpful. Any help would be appreciated.

AltBrian
  • 2,392
  • 9
  • 29
  • 58
  • The first thing I'd try is to either upload a `favicon.ico` file (to your public folder, I guess) or to remove the reference from the index view. –  Apr 11 '18 at 10:20
  • Could that be anything? I have converted some of the png files in the app to .ico. How do I know if there is a reference to it in the index.html file ? – AltBrian Apr 11 '18 at 10:24
  • Open the index file and check the `` for a `` line that references `favicon.ico`. Remove it. –  Apr 11 '18 at 10:31
  • There is no link to favicon.ico in the index.html page. I have added one but it does not show up locally. `````` – AltBrian Apr 11 '18 at 10:39
  • The server is trying to load `/favicon.ico` because it is requested by the browser. For some reason your app crashes while doing that, instead of replying with a 404 Not found error. Without seeing your app's source code, all we can do is guess wildly. –  Apr 11 '18 at 10:44
  • Is there a way for me to show you my source code? – AltBrian Apr 11 '18 at 10:45
  • You can put relevant parts in the question, or put it on github. Btw, the website also tries to load `./public/main.js` which does result in a 404 error. –  Apr 11 '18 at 10:47
  • I will update and give you the link to my github. – AltBrian Apr 11 '18 at 10:49
  • here is the link https://github.com/amidabrian51/Rock_Paper_Scissors – AltBrian Apr 11 '18 at 10:54
  • I'll take a look –  Apr 11 '18 at 10:56
  • Alright, the main problem is your way of serving files. While you do catch 404 errors, a better way is to not rely on `try/catch` to do so. In this case, `fs.exists()` is a much better solution. An even better solution though is to use an existing solution like `express` to serve your files. Btw, I'm pretty sure that `/favicon.ico` is requested by the browser; it wants to put it in the tab so just goes ahead and requests it. –  Apr 11 '18 at 11:10
  • So what do you suggest that I do now? If you don’t mind me asking. – AltBrian Apr 11 '18 at 11:16
  • You can `npm install http-server` and use `require("http-server").createServer().listen(3000);` in your `index.js`. It'll serve the `public` folder by default. –  Apr 11 '18 at 11:24
  • I am now getting the following error ```brianpat-rock-paper-scissors.herokuapp.com didn’t send any data. ERR_EMPTY_RESPONSE``` – AltBrian Apr 11 '18 at 11:50
  • It is now giving me the following in the logs ```at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=brianpat-rock-paper-scissors.herokuapp.com request_id=71e45c5c-b252-4037-bfb0-d1443534ec3d fwd="94.174.32.117" dyno= connect= service= status=503 bytes= protocol=https``` – AltBrian Apr 11 '18 at 11:56
  • Here's what worked for me: `require("http-server").createServer().listen(process.env.PORT);`, then on heroku, under Settings -> Config Variables, add `PORT`: `8080` It's online here: https://rps-test-so.herokuapp.com/ (the key isn't using a variable but the proper port, I guess) –  Apr 11 '18 at 12:11
  • I am now getting the following error `` brianpat-rock-paper-scissors.git Failed to load resource: the server responded with a status of 405 (Method Not Allowed)`` ARRRGH – AltBrian Apr 11 '18 at 12:21
  • It worked! Thank you very much Chris G. Can you put your answer above and I will upvote it. – AltBrian Apr 11 '18 at 12:25
  • Possible duplicate of [Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)](https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-of) –  Apr 11 '18 at 13:36

0 Answers0