'Can not access production env rails app running local on localhost:3000
I can run my rails app fine in developemnt using:
rails s then going to localhost:3000
However, I need to test production and tried
rails s -e production, however, when I go to localhost:3000, I see nothing happen in my rails server.
=> Booting Puma
=> Rails 5.2.3 application starting in production
=> Run `rails server -h` for more startup options
Set localhost 3000 as the default_url_option ----
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Why can't I access my production rails app? Is there any specific tutorial on how to run a production env on a local machine? I am using Mac OSX High Sierra.
Solution 1:[1]
I don't believe rails logs requests to the console in production like it does in development, so you shouldn't see anything happen.
Try running rake assets:precompile before starting the server. Also, make sure you have created a database for your production environment, and that you have migrated. You can create the database like so: rake db:create RAILS_ENV=production, then just migrate like this rake db:migrate RAILS_ENV=production
If you are still having issues getting your application to run in production, check the production log.
Solution 2:[2]
Ran into same issue, in my case I was building small API application. And didnt have a route for /. Checking log/production.log helped me figuring out whats wrong, since production environment doesnt write anything in console.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mathias Pfeil |
| Solution 2 | A. Askarov |
