Skip to content

mysql socket error on Google Cloud Run with Rails 6.1 #106

Open
@aaron-lorenz

Description

I get the following error when adding the exception_handler config information on production...while assets are precompiling...db: option is set to true. Removing the config info clears the error...as does setting db: option to nil. Any help would be appreciated...thanks

RUN RAILS_ENV=production bundle exec rake assets:precompile
---> Running in 5f9658d8ba43
rake aborted!
ActiveRecord::ConnectionNotEstablished: Can't connect to local MySQL server through socket '/cloudsql/' (2)
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/mysql2_adapter.rb:45:in rescue in new_client' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/mysql2_adapter.rb:39:in new_client'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/mysql2_adapter.rb:23:in mysql2_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in public_send'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in new_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in checkout_new_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in try_to_checkout_new_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in acquire_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in checkout' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in retrieve_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:327:in retrieve_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:283:in connection' /app/vendor/bundle/ruby/3.0.0/gems/exception_handler-0.8.0.2/lib/exception_handler/config.rb:143:in initialize'
/app/vendor/bundle/ruby/3.0.0/gems/exception_handler-0.8.0.2/lib/exception_handler/engine.rb:45:in new' /app/vendor/bundle/ruby/3.0.0/gems/exception_handler-0.8.0.2/lib/exception_handler/engine.rb:45:in block in class:Engine'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:32:in instance_exec' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:32:in run'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:61:in block in run_initializers' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:60:in run_initializers'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/application.rb:391:in initialize!' /app/config/environment.rb:5:in

'
/app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require' /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require'
/app/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in require' /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in block in require'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in load_dependency' /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in require'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/application.rb:367:in require_environment!' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/application.rb:533:in block in run_tasks_blocks'
/app/vendor/bundle/ruby/3.0.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in block (2 levels) in define' /app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in load' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in kernel_load'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:23:in run' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli.rb:484:in exec'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor.rb:392:in dispatch' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli.rb:31:in dispatch'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/base.rb:485:in start' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli.rb:25:in start'
/usr/local/bundle/gems/bundler-2.3.7/exe/bundle:48:in block in <top (required)>' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/friendly_errors.rb:103:in with_friendly_errors'
/usr/local/bundle/gems/bundler-2.3.7/exe/bundle:36:in <top (required)>' /usr/local/bundle/bin/bundle:23:in load'
/usr/local/bundle/bin/bundle:23:in <main>' Caused by: Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/cloudsql/' (2) /app/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in connect'
/app/vendor/bundle/ruby/3.0.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in initialize' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/mysql2_adapter.rb:40:in new'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/mysql2_adapter.rb:40:in new_client' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/mysql2_adapter.rb:23:in mysql2_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in public_send' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in new_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in checkout_new_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in try_to_checkout_new_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in acquire_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in checkout'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in retrieve_connection'
/app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:327:in retrieve_connection' /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:283:in connection'
/app/vendor/bundle/ruby/3.0.0/gems/exception_handler-0.8.0.2/lib/exception_handler/config.rb:143:in initialize' /app/vendor/bundle/ruby/3.0.0/gems/exception_handler-0.8.0.2/lib/exception_handler/engine.rb:45:in new'
/app/vendor/bundle/ruby/3.0.0/gems/exception_handler-0.8.0.2/lib/exception_handler/engine.rb:45:in block in <class:Engine>' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:32:in instance_exec'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:32:in run' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:61:in block in run_initializers'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/initializable.rb:60:in run_initializers' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/application.rb:391:in initialize!'
/app/config/environment.rb:5:in <main>' /app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require'
/app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require' /app/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in require'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in block in require' /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in load_dependency'
/app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in require' /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/application.rb:367:in require_environment!'
/app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.6/lib/rails/application.rb:533:in block in run_tasks_blocks' /app/vendor/bundle/ruby/3.0.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in block (2 levels) in define'
/app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in <top (required)>' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in load'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:58:in kernel_load' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli/exec.rb:23:in run'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli.rb:484:in exec' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor.rb:392:in dispatch'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli.rb:31:in dispatch' /usr/local/bundle/gems/bundler-2.3.7/lib/bundler/vendor/thor/lib/thor/base.rb:485:in start'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/cli.rb:25:in start' /usr/local/bundle/gems/bundler-2.3.7/exe/bundle:48:in block in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.7/lib/bundler/friendly_errors.rb:103:in with_friendly_errors' /usr/local/bundle/gems/bundler-2.3.7/exe/bundle:36:in <top (required)>'
/usr/local/bundle/bin/bundle:23:in load' /usr/local/bundle/bin/bundle:23:in '

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions