venkatesh
venkatesh

Reputation: 21

How can I run a Rails app in production mode?

How to start Rails App in production mode? Can any one give me clear explanation

I tried rails server -e production but it gives me error in log file saying

Mysql2::Error Access denied for user ''@'localhost'

Upvotes: 2

Views: 2831

Answers (3)

Agis
Agis

Reputation: 33626

The command you run is perfectly fine.

It's your configuration files (config/database.yml) that are missing the correct settings for the production environment though.

Upvotes: 3

Lamya
Lamya

Reputation: 361

Try RAILS_ENV=production rails s

Upvotes: 3

Miknash
Miknash

Reputation: 7948

To start server in production mode type :

RAILS_ENV=production rails s

in the console.

Here is my output for this:

=> Booting Thin
=> Rails 4.1.0 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

as you can see in the second line it is in production.

Be aware that RAILS_ENV is case sensitive.

Seems like you are getting error because your credentials are incorrect, not because your RAILS_ENV is production...

Several things can cause this behaviour.

  1. Double check if you created your database for production ENV.
  2. Check credentials you use for connection on database.
  3. Your mySQL server is not running.

Upvotes: 1

Related Questions