Background worker connection to external database failure

When I view the log of my background worker, I see the error
ActiveRecord::ConnectionNotEstablished: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I am running a Rails Application which connects to an external DB and my database.yml file contains this


# SQLite. Versions 3.8.0 and up are supported.
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem "sqlite3"
#
default: &default
  adapter: mysql2
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  encoding: utf8
  database: easy_release
  username: root
  password: 


  # host: <%= ENV['DB_HOST'] %>
  # database: <%= ENV['DB_NAME'] %>
  # username: <%= ENV['DB_USERNAME'] %>
  # password: <%= ENV['DB_PASSWORD'] %>
  # ssl_mode: verify_identity
  # sslca: "/etc/ssl/cert.pem"


# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

staging:
  <<: *default
  encoding: utf8
  host: <%= ENV['DB_HOST'] %>
  database: <%= ENV['DB_NAME'] %>
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  ssl_mode: verify_identity
  sslca: "/etc/ssl/certs/ca-certificates.crt"


production:
  <<: *default
  encoding: utf8
  host: <%= ENV['DB_HOST'] %>
  database: <%= ENV['DB_NAME'] %>
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  ssl_mode: verify_identity
  sslca: "/etc/ssl/certs/ca-certificates.crt"

I am not sure of how to resolve this.

Hi,

Are all the DB_* environment variables the database.yml references set correctly on the service?

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.