Rails: Production Rails console won't start

Related searches

Everything works fine on my OS X development laptop.

Deploy the app to production and it runs and displays data as expected.

However, when I try to run the Rails console on the production server I get an error...

$ rails console -e production
    in `connect': Can't connect to local MySQL server through socket 
        '/tmp/mysql.sock' (2) (Mysql2::Error)

    from /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
    from /opt/deployed_rails_apps/con_app_rails_3/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'

I tried removing socket: /tmp/mysql.sock from database.yml -- same result.

Although the app runs, I do need to be able to access the console in production as well to perform certain tasks.

I am able to connect to the MySQL server using the MySQL command line client.

ruby 1.9.3p125

Rails 3.2.2

mysql2 gem 0.3.11

MySQL server: 5.1.61

Production host: Linux 2.6.32-220.4.2.el6.x86_64


  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: con_app_rails_3_development
  pool: 5
  username: root
  socket: /tmp/mysql.sock

  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: con_app_rails_3_test
  pool: 5
  username: root
  socket: /tmp/mysql.sock

  adapter: mysql2
  encoding: utf8
  reconnect: false
  host: dbhost
  database: con_app_rails_3_production
  pool: 5
  username: xxxx
  password: xxxx
  socket: /tmp/mysql.sock

Solved it.

All I needed to do was...

$ RAILS_ENV=production bundle exec rails console

The Rails Command Line — Ruby on Rails Guides, rails new; bin/rails server; bin/rails generate; bin/rails console; bin/rails dbconsole ; bin/rails runner; bin/rails destroy bin/rails server -e production -p 4000. $ rails console -e production --sandbox Loading production environment in sandbox Any modifications you make will be rolled back on exit >> Then, when you really need to change production data, you can switch back to the live console.

Another way to do this:

./script/rails console production

A Safer Rails Console, The console is oftentimes used in a production environment, as it is the quickest method to glean information about any problems. With great� rails console. And enter an In production, my app work perfectly, no problems, no errors, but when i use rails console production and enter for example User.all i

I solved with run:

 RAILS_ENV=production bundle exec rails c

more details on link

rails console on production uses spring � Issue #318 � rails/spring , I have been using spring since rails 4.1 released and I really like it. Yesterday we found that there's spring processes running on our production� bin/bundle exec rake gitlab:env:info RAILS_ENV=production. I don't know what this command does. When I tried it, it did not start the console. It just printed out some interesting information about the runtime environment. I'm running the "official" Synology Docker install from its Package Center. Currently is installs version 11.0.4.

You can also solve this by appending the --environment=production argument to the rails c or rails console command

rails c --environment=production

That's all.

I hope this helps

Unable to access `rails console` or see `rails -v` on production , Hello, I have a rails 4.2.3 application on production rbenv 0.4.0 / ruby question/ discussion on stackoverflow, but it doesn't solve the issue. The Rails console loads in the development environment by default, but if you pass the production parameter to the rails c command, you can run the Rails console in the production environment too. You can instantiate class objects, such as a product object from the class Product in my example app in and create a record for it like so: p

Rails Console Shortcuts, Tips, and Tricks, As a Rails developer, you'll end up spending a lot of time in the Rails console . class, the movie object won't have that new method even when you call reload! rails console -e production --sandbox Loading production� Rails works outside the scope of HTTP (web). Because it doesn’t have HTML files, it cannot rely on web server software to deliver pre-built responses (as you would a static HTML site).

We all love to enter the Rails console to try out some stuff. It's just a rails c away in development. But what if you want to view or fetch some specific data on your remote production server (and you're not on Heroku)? If you already deploy your app with Capistrano, why not use it for this task? There are a lot of different snippets out there.

I have been using spring since rails 4.1 released and I really like it. Yesterday we found that there's spring processes running on our production servers. We traced down and found that spring was started when we used rails console with command bundle exec rails console production. We don't want it to be used on production.

  • I didn't need to do bundle exec, but specifying RAILS_ENV=production FIRST on the command line was important.