By hiagos93
I can connect to the DO’s db from the app server through the flag command just fine, that’s how I exported the database .sql there successfully.
But the rails app is another story, it’s like it’s trying to look for a local mysql server even though I believe I’ve specified everything in the database.yml file. The error:
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
The database.yml file:
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: password
socket: /var/run/mysqld/mysqld.sock
production:
<<: *default
username: doadmin
password: password
host: clients1-do-user-2960833-0.db.ondigitalocean.com
port: 25060
database: bw
sslmode: REQUIRED
sslca: /root/ca-certificate.crt
url: mysql2://doadmin:password@clients1-do-user-2960833-0.db.ondigitalocean.com:25060/bw?ssl-mode=REQUIRED
Running ‘ufw status’:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
3306 ALLOW Anywhere
Nginx Full ALLOW Anywhere
25060 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
3306 (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
25060 (v6) ALLOW Anywhere (v6)
I only have mysql-client installed, version 8 same as the DO server.
mysql Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)
Puma is starting rails with production as environment, as it should.
IDK what else to put in the database.yml to tell rails to stop looking into a local server.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there @hiagos93,
According to the error that you are getting I think that your Rails App is trying to connect to the default profile as in there you’ve specified the /var/run/mysqld/mysqld.sock socket.
Besides that, your production configuration looks correct.
I think that you just need to set your Rails env to production and it should pick up the correct database config.
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.