Topic: Can't Connect to Remote Database

Scenario:
I need to separate the server for the database and rails app. I set my database.yml as follows:

production:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: main_production
  pool: 5
  username: root
  password: ****
  host: [db_server_ip]
  port: 3306
  socket: /var/run/mysqld/mysqld.sock

But I get an internal error 500 and in my production.log:

Mysql::Error (Can't connect to MySQL server on '[db_server_ip]' (111)):
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:505:in `real_connect'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:505:in `connect'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:183:in `initialize'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `new'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `mysql_connection'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in `send'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in `connection='
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:in `retrieve_connection'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
    /vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
    /vendor/rails/railties/lib/fcgi_handler.rb:103:in `process_request'
    /vendor/rails/railties/lib/fcgi_handler.rb:153:in `with_signal_handler'
    /vendor/rails/railties/lib/fcgi_handler.rb:101:in `process_request'
    /vendor/rails/railties/lib/fcgi_handler.rb:78:in `process_each_request'
    /usr/lib/ruby/1.8/fcgi.rb:606:in `each_cgi'
    /vendor/rails/railties/lib/fcgi_handler.rb:77:in `process_each_request'
    /vendor/rails/railties/lib/fcgi_handler.rb:76:in `catch'
    /vendor/rails/railties/lib/fcgi_handler.rb:76:in `process_each_request'
    /vendor/rails/railties/lib/fcgi_handler.rb:50:in `process!'
    /vendor/rails/railties/lib/fcgi_handler.rb:24:in `process!'
    public/dispatch.fcgi:25

Rendering /var/www/spcfmain/public/500.html (500 Internal Server Error)

Is this really possible? if yes, is there something I forgot to set? TIA!

Last edited by ajibanda (2010-05-06 00:11:29)

Re: Can't Connect to Remote Database

have you solved it?