1

Finally deployed my ruby on rails 3.2 app but when trying to open it from the browser I'm getting a 500 error (production.log gives)

Errno::ENOENT (No such file or directory - Problem opening database)
  • installed rvm rails 3.2 ruby latest
  • working cap deploy with nginx and unicorn
  • rake db:migrate RAILS_ENV=production in production terminal => no errors

My production database.yml ( both tried with and without path to mysql socket, mysqld running fine mysql from terminal i can connect and see all tables in db )

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: paintings_production
  pool: 5
  username: paintings
  password: mypass
  socket: /var/lib/mysql/mysql.sock
Rubytastic
  • 15,001
  • 18
  • 87
  • 175
  • Try using strace on the application instance's pid. You'll get a lot of output but it'll show you which open() attempt is resulting in the ENOENT. – noodl Mar 21 '12 at 23:23
  • could you explain that a bit more please I don't think I understand how you mean this exactly. what pid? of the unicorn process? – Rubytastic Mar 21 '12 at 23:30
  • Yes. As root run the strace command specifying the pid of the process you want to watch. I'm assuming linux; there are alternatives for other OSes. It'll show you system calls and their results. See man strace. – noodl Mar 21 '12 at 23:33
  • I suspect your path to the socket could be wrong (or it's permissions). By default the socket file is in **/var/run/mysqld/mysql.sock** (not **lib**). What does `ls -l /var/lib/mysql/mysql.sock` output? – user569825 Mar 22 '12 at 06:35
  • @user569825 that gives me a ls -l /var/lib/mysql/mysql.sock srwxrwxrwx 1 mysql mysql 0 Mar 20 08:47 /var/lib/mysql/mysql.sock – Rubytastic Mar 22 '12 at 08:18
  • I tried strace -p 3022 wich is the pid of the unicorn after stopping and starting it, this gives no real insights whatsoever perhaps I should trace the mysqld to see if it connects I try that also but this hasn't helped fixing the issue – Rubytastic Mar 23 '12 at 16:00
  • Can you start the app in dev mode from this install? Just switch the environment you are using for unicorn. Additionally, you may want to change your debug level in your config/environments/production.rb so you can see more info. – Ben Miller Mar 25 '12 at 04:03
  • Cannot run it in dev mode since I don't want dev databases created on server side, Tried setting debug level to debug in production environment but still same error, this is getting pretty frustrating – Rubytastic Mar 25 '12 at 14:23

1 Answers1

1

Since you've confimed your socket file exists:

/var/lib/mysql/mysql.sock

...but the error message says no such file or directory, you have a permissions problem.

Or perhaps your mysql server isn't configured to use the same socket correctly?

You can find a full mysql/rails unix socket debugging info here: Ruby on Rails 3 Can't connect to local MySQL server through socket '/tmp/mysql.sock' on OSX

Community
  • 1
  • 1
Winfield
  • 18,985
  • 3
  • 52
  • 65