28
votes

I have followed book until chapter 5 finished and it's working OK in my linux workstation when I push to Heroku, all data pushed correctly but when I try to open Heroku (http://vivid-sky-685.heroku.com)

I get a 404 message.

The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.

Below is my Gemfile for application

source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3'

group :development do
  gem 'rspec-rails', '2.5.0'
end

group :test do
  gem 'rspec', '2.5.0'
  gem 'webrat', '0.7.1'
  gem 'spork', '0.9.0.rc4'
end

gem 'rake','~> 0.8.7'

Any ideas what could be going wrong?

@odin here is my heroku logs , thanks

2011-09-11T10:41:57+00:00 heroku[router]: GET vivid-sky-685.heroku.com/y dyno=web.1 queue=0 wait=0ms service=5ms status=404 bytes=728
2011-09-11T10:41:57+00:00 app[web.1]: 
2011-09-11T10:41:57+00:00 app[web.1]: 
2011-09-11T10:41:57+00:00 app[web.1]: Started GET "/y" for 93.186.31.80 at 2011-09-11 03:41:57 -0700
2011-09-11T10:41:57+00:00 app[web.1]: 
2011-09-11T10:41:57+00:00 app[web.1]: ActionController::RoutingError (No route matches "/y"):
2011-09-11T10:41:57+00:00 app[web.1]:   
2011-09-11T10:41:57+00:00 app[web.1]: 
2011-09-11T10:41:57+00:00 app[web.1]: 
2011-09-11T10:41:57+00:00 heroku[nginx]: 93.186.31.80 - - [11/Sep/2011:03:41:57 -0700] "GET /y HTTP/1.1" 404 728 "-" "Mozilla/5.0 (BlackBerry; U; BlackBerry 9300; en) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.546 Mobile Safari/534.8+" vivid-sky-685.heroku.com
2011-09-11T11:45:28+00:00 heroku[web.1]: Idl

2011-09-11T11:45:29+00:00 heroku[web.1]: State changed from up to down
2011-09-11T11:45:29+00:00 heroku[web.1]: State changed from down to created
2011-09-11T11:45:29+00:00 heroku[web.1]: State changed from created to starting
2011-09-11T11:45:30+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-11T11:45:30+00:00 app[web.1]: >> Stopping ...
2011-09-11T11:45:30+00:00 heroku[web.1]: Process exited
2011-09-11T11:45:30+00:00 heroku[web.1]: Starting process with command `thin -p 16738 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-11T11:45:33+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-11T11:45:33+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-11T11:45:33+00:00 app[web.1]: >> Listening on 0.0.0.0:16738, CTRL+C to stop
2011-09-11T11:45:33+00:00 heroku[web.1]: State changed from starting to up
2011-09-11T12:53:00+00:00 heroku[web.1]: Idling
2011-09-11T12:53:01+00:00 heroku[web.1]: State changed from up to down
2011-09-11T12:53:02+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-11T12:53:02+00:00 app[web.1]: >> Stopping ...
2011-09-11T12:53:02+00:00 heroku[web.1]: Process exited
2011-09-11T13:18:21+00:00 heroku[rake.1]: State changed from created to starting
2011-09-11T13:18:23+00:00 app[rake.1]: Awaiting client
2011-09-11T13:18:23+00:00 app[rake.1]: Starting process with command `bundle exec rake db:migrate`


2011-09-11T13:18:26+00:00 heroku[rake.1]: Process exited
2011-09-11T13:18:26+00:00 heroku[rake.1]: State changed from up to complete
2011-09-11T13:20:02+00:00 heroku[web.1]: Unidling
2011-09-11T13:20:02+00:00 heroku[web.1]: State changed from down to created
2011-09-11T13:20:02+00:00 heroku[web.1]: State changed from created to starting
2011-09-11T13:20:04+00:00 heroku[web.1]: Starting process with command `thin -p 48393 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-11T13:20:06+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-11T13:20:06+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-11T13:20:06+00:00 app[web.1]: >> Listening on 0.0.0.0:48393, CTRL+C to stop
2011-09-11T13:20:07+00:00 heroku[web.1]: State changed from starting to up
2011-09-11T13:20:07+00:00 app[web.1]: 
2011-09-11T13:20:07+00:00 app[web.1]: 
2011-09-11T13:20:07+00:00 app[web.1]: Started GET "/" for 118.137.144.220 at 2011-09-11 06:20:07 -0700
2011-09-11T13:20:08+00:00 app[web.1]: 
2011-09-11T13:20:08+00:00 app[web.1]: ActionController::RoutingError (uninitialized constant PagesController):
2011-09-11T13:20:08+00:00 app[web.1]:   
2011-09-11T13:20:08+00:00 app[web.1]: 
2011-09-11T13:20:08+00:00 app[web.1]: 
2011-09-11T13:20:08+00:00 heroku[router]: GET vivid-sky-685.heroku.com/ dyno=web.1 queue=0 wait=0ms service=403ms status=404 bytes=728
2011-09-11T13:20:08+00:00 heroku[nginx]: 118.137.144.220 - - [11/Sep/2011:06:20:08 -0700] "GET / HTTP/1.1" 404 728 "-" "Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0" vivid-sky-685.heroku.com
13
@widjajayd In your console type "heroku logs" and post the print-out you get.Hishalv
Just so you know your not on your own, I'm suffering from this problem to. Did you ever find the cause?Abe Petrillo
I had this problem. I was working on a contact form on the route of contact-me which i had defined in routes.rb. When i visited the url supplied by heroku (e.g www.example_heroku_url.com/) i got the 404 like you. it was because i hadn't defined a root path or index view. so when i visited www.example_heroku_url.com/contact-me It worked. Really silly mistake but thought i'd share in case it helps someoneSarah

13 Answers

30
votes

I know it's an old problem but I ran into it too. I realized I didn't change the root route in config/routes.rb before pushing. Not changing it might result in a welcome page locally, but on heroku it will get the above error.

11
votes

I got the same problem; however, after changing 1 line code of production.rb located in config/environments/production.rb from

config.assets.compile = false

to

config.assets.compile = true

commit the new change. Then my sample app works fine on heroku

7
votes

I'm using postgresql, and I also had page not showing up on heroku.

This command fixed it:

heroku run rake db:setup

and then

heroku rake db:migrate

I had migrated before, but hadn't done the setup first.

I also had tried setting

config.assets.compile = true

in production.rb, but that made no difference.

4
votes

Have you tried running in production mode locally? Try rails server -e production and see if you get the same error, which you can then debug. Also make sure you've done heroku rake db:migrate.

2
votes

In my case it was a missing starting page that did not cause a problem in development mode but did cause the above issue on heroku. The accepted answer on this thread sheds more light.

2
votes

Ran into this problem as well. Solved it by setting a root route. In my case, root 'pages#home' in config/routes.rb

If the root route is not set, you are redirected to localhost:3000. Hence,

The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.

2
votes

1. Always set a root in routes. That's rails 101

I wouldn't go for making asset pre-compilation false all the time. For production app I feel it enhances the overall speed if assets have been pre-compiled.

2. As a rule of thumb I always run rake assets:precompile before pushing to git. Please try it. and then commit to git repository and then heroku. Do heroku restart

3. Another cause could be heroku rake db:migrate, please check if you did it

4. Also this is my Gemfile setup for the development and production groups

group :development do 
    gem 'sqlite3'        
end

group :production do    
    gem 'pg'
    gem 'rails_12factor'
    gem 'heroku-deflater'   
end
0
votes

I had a very similiar issue with heroku, found the answer from this question:

RefineryCMS routes for Home page doesn't work

To save you reading, the solution was to update "Home" using Advanced Options, there is a question:

"Forward this page to another website or page"

Fill this in with a / and it should work. This sounds a little backwards, as its actually setting /my_page to redirect to "/". But the way to think of it is:

Refinery pages extension is looking for a page with the url '/' to be the home page. So by telling the page titled "Home" that you want it to have the url '/' you're setting it as the definitive homepage as far as Refinery pages extension is concerned. (quote from @Philip Arndt)

0
votes

So I had to run in this order and it worked for me

$ heroku rake db:migrate
$ heroku run rake db:setup
0
votes

Specify Ruby version in app Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the ruby DSL in your Gemfile.

At the end of Gemfile add:

ruby "2.4.1"

0
votes

I had the same problem, but the thing is that the app is missing the home like root. The default home page for Heroku is this HTMLthe default page. But if you try all your defined routes they will work like:

appname.herokuapp.com/route

0
votes

I got the same error but realized that I hadn't change the HTML verb from GET to ROOT in config/routes.rb file.

It was get "/hello", to: "application#hello"

I updated it to root "application#hello"

I then pushed it to git and deployed it to production.

0
votes

I was facing the same error because I pushed same non-master branch to heroku master using this command git push heroku master . Which obviously cause conflicts.

I also checked the routes using heroku run rake routes. But the output was not my actual routes. Not even single one.
The proper way to push your non-master branch to heroku master is

git push -f heroku your_branch_name:master