Seems to occur if mysqld uses random ports on startup. Fix: Add the following port to connection options port : '/var/run/mysql/mysql.sock'