Deeks
Deeks

Reputation: 53

Error when Yeoman app deployed to Heroku

I get the following error after deploying my Yeoman app to Heroku

GET http://myapp.herokuapp.com/favicon.ico 503 (Service Unavailable)

I have a favicon image, and everything runs fine locally with the favicon image appearing. I'm not sure how to fix this error or why it is being caused in the first place.

Here is all my code: https://github.com/dkretsch12/MyHerokuApp
And I push it to Heroku with the following commands:
git add .
git commit -am "still stuck"
git push heroku master

Upvotes: 1

Views: 5679

Answers (2)

George.
George.

Reputation: 1008

I had the same 503 service unavailable error favicon.ico, when attempting to open a Heroku deployed Rails/React app. I was stuck on this bug for at least an hour, and thought this post may provide insight on how I solved the 503 favicon issue.

Step 1: I tried to locate a favicon.ico file in my rails app, tried creating my own favicon.ico file, and placing said file in the root and other directories. I got the same error...

Step 2. I ran the following in terminal: heroku logs -t, scrolled up and found the actual error to be Heroku failing to support gem sqlite3.

An error occurred while installing sqlite3 (1.3.13), and Bundler cannot remote: continue. remote: Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling. remote: remote: In Gemfile: remote: sqlite3 remote: ! remote: ! Failed to install gems via Bundler. remote: ! Detected sqlite3 gem which is not supported on Heroku: remote: ! https://devcenter.heroku.com/articles/sqlite3

More info as to why is here.

Step 3: After learning more, I discovered I can either follow the heroku documentation to figure out how to use sqlite3 with heroku, or change DB. I chose to change DB to postgres, and I found two amazing resources to help with that:

how to change your rails app database from sqlite to postgresql before deploying to heroku. Change from SQLite to PostgreSQL in a fresh Rails project

Step 4: After doing so, I got a 500 internal server error, went to heroku logs -t again, and found out that my tables did not exist on heroku. From there, I knew I had to migrate rails DB to heroku using the following command: heroku run bundle exec rails:db migrate. Pushed to heroku and that did the trick.

TLDR: A status 503 unable to find path="/favicon.ico" doesn't necessarily mean the issue stems from a missing favicon.ico in a heroku deployed app. A more insightful method for determining root cause is to use heroku logs -t.

Upvotes: 0

devboell
devboell

Reputation: 1190

I also ran into this, and for me it turned out the '503 (Service Unavailable)' error was not the real error. Try: heroku logs --app [your-app-name] and see if it gives you more info.

In my case it was that Heroku was looking for npm start script, which I had not specified, but is required by Heroku. Looking at your package.json I see you don't have it either, so that might be the place to start.

edit

I think the underlying reason for this error is that by default Heroku expects a webserver or some kind executable to be running in the background. It's needed because otherwise incoming requests would not be handled. So it has to be provided by the programmer, and after installation Heroku will run it, either by npm start or by what is specified in the Procfile.

I my case I needed a webserver anyway, so I just created a server.js module where I implemented a small express app. Then in package.json I specified:

"scripts": { "start": "node server.js", ... },

But this may not be the right solution for you, it depends on what you want with your app. I don't know anything about Grunt or Angular, so I can't help you there. I did find this question which may be of value to you. I also recommend reading the docs on Heroku Dev Center

Upvotes: 2

Related Questions