User4432432432 User4432432432 - 1 month ago 14
Ruby Question

started the rails server but localhost page wont load

I started the rails server

$ bundle exec rails s -p 3001
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-11-03 19:29:30] INFO WEBrick 1.3.1
[2016-11-03 19:29:30] INFO ruby 2.2.5 (2016-04-26) [x86_64-darwin15]
[2016-11-03 19:29:30] INFO WEBrick::HTTPServer#start: pid=30949 port=3001


But when i go to the http://localhost:3001 i get error: This localhost page can’t be found

This is the data i see in terminal after i go on http://locahhost:3001
Any idea what is wrong?

{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "DEBUG",
"type": "none",
"message": " \u001b[1m\u001b[36mSQL (57.9ms)\u001b[0m \u001b[1mUSE [peak]\u001b[0m"
}
{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "INFO",
"type": "database.query",
"request_id": "67b064b7-f6a3-414e-9a39-da4f851fc8dd",
"connection_id": "70230967245540",
"event": "SQL",
"query_id": "a15f740d4daad1a81dbc7e0df1ccf3e5",
"query": "USE [peak]",
"duration": "58.3"
}
{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "INFO",
"type": "none",
"message": "Processing by HomeController#index as HTML"
}
{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "INFO",
"type": "none",
"message": " Rendered text template (0.0ms)"
}
{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "INFO",
"type": "view.render",
"request_id": "67b064b7-f6a3-414e-9a39-da4f851fc8dd",
"template": "text template",
"layout": null,
"duration": "0.4"
}
{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "INFO",
"type": "none",
"message": "Completed 404 Not Found in 9ms (Views: 8.1ms | ActiveRecord: 0.0ms)"
}
{
"timestamp": "2016-11-03T23:35:40Z",
"severity": "INFO",
"type": "application.request",
"request_id": "67b064b7-f6a3-414e-9a39-da4f851fc8dd",
"method": "GET",
"status": 404,
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
"referrer": null,
"forwarded_for": null,
"url_scheme": "http",
"url_host": "localhost",
"url_port": "3001",
"url_path": "/",
"url_query": null,
"rails_controller": "home",
"rails_action": "index",
"clean_path": "/",
"remote_ip": "::1",
"remote_host": "::1",
"duration": "1108.02",
"message": "Not Found",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"content_type": "text/plain; charset=utf-8"
}

Answer
Completed 404 Not Found in 9ms (Views: 8.1ms | ActiveRecord: 0.0ms)

Your server and your app are running fine; your browser is loading the page at http://localhost:3001 perfectly fine.

The problem is that your app is returning a 404 Not Found - in other words, Rails can't match a controller/action to the root route.

Look in your config/routes.rb file. You should have a route defined for root, such as

root :to => 'home#index'

If you're accessing a path directly (such as http://localhost:3001/example/path), make sure you have a route defined for that:

get 'example/path', :to => 'controller#action'

Finally, make sure the relevant controller exists and has a method definiton for the action your route maps to (i.e. for the root example, make sure app/controllers/home_controller.rb exists and it has an index method defined).