title: Can't connect to MySQL server on 'myhost.com' (4)
body: <p>I'm able to connect to the remote database from a MySQL client and using terminal as well. But when trying to access the database from the Rails app, I got this error:</p>
  
  <p>Mysql2::Error (Can't connect to MySQL server on 'myhost.com' (4))</p>
  
  <p>My database.yml has the following configuration for development:</p>
  
  <pre><code>adapter: mysql2
  encoding: utf8
  reconnect: false
  host: myhost.com
  port: 3306
  database: the_database
  pool: 5
  username: myusername
  password: mypassword
  socket: /var/lib/mysql/mysql.sock
  </code></pre>
  
  <p>I have changed the name of the host to post this question, as the username, password and database.</p>
  
  <p>Googling around, I could see different reasons for not connecting to the database, but none of them are similar to mine and with this code 4 (is that an error code?).</p>
  
  <p>I'm new to Rails, so I have no clue what should I do next in order to fix it. I have double checked my configuration, even the socket. I've personally checked on the server side and this is the right path to the socket.</p>
  
  <p>I'm not sure if it's relevant, but this user has read only access to this database.</p>
  
  <p>I'm using Rails 3.2.8 and Ruby 1.8.7.</p>