I'm trying to install a web app on my Ubuntu 12.04 server. The app is based on PHP and MySQL and I've got LAMP already working OK on my server - infact I've already got other apps working on PHP & MySQL already installed and working OK.

The problem I'm facing is, that when I try to run this app I get the error

Error: A Database connection using "Mysql" was missing or unable to connect. The database server returned this error: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '' (111)

I have double and triple checked the username and password that I've put into the database.php and have confirmed that it's the same login credentials as what I use for phpMyAdmin and I'm even referring to the correct database (which as can be seen in phpMyAdmin, has been setup correctly.

For the install, I have followed the instructions at http://sourceforge.net/p/coopos/wiki/Install/ The only place I have differed is, "Step III. Configure the Virtual Host" - reason being, I cannot move from "/var/www" to "/home/username/public_html" as I already have other apps running under "/var/www"

My installation of the app (with all the error messages) can be seen at

Would really appreciate some help on this, pls.


It is a permissions error, it means you must check

  • Your database could be accesed from other hosts than localhost. if your localhost is, then use localhost, cause is no localhost, then your database must have permission from access
  • You database user, has permission from the host that you refer, it means, youruser@
  • The port is open through a firewall or other
  • Finally, you could do a ping to your database host

Check that and then send a comment

  • You mean file permissions? 'cos if I change 'host' in database.php to either 'localhost' or '' then I just get a 404 Page Not Found; but if I use the server's domain or IP# ( then one see's what is currently available by going to – user93078 Jun 11 '13 at 14:27
  • I thought we are getting confused, I mean, one host is use app host, where your app is hosted, and one host is the database host, you must check on your database, wich user you you have and this user is accessed from... if you have a phpmyadmin or some kind of front end, check your database users, first at all you must check that, then you must compare with you php app – Carlos Jun 11 '13 at 14:36
  • Error (111) is not a permissions error. – Michael - sqlbot Jun 11 '13 at 15:03
  • it is a kind of access denied error dev.mysql.com/doc/refman/5.0/es/access-denied.html as the manual says, your could try to do a shell> netstat -ln | grep mysql for been sure that your server is running – Carlos Jun 11 '13 at 15:15
sqlbot@dev:~$ /usr/local/mysql/bin/perror 111
OS error code 111:  Connection refused

Error code 111 (in parentheses, at the end) means "Connection refused." It is not a permissions error. It does not mean authentication failed. It means you are either trying to connect to the MySQL server using the wrong IP address or port, or the destination MySQL Server at the specified IP address and port isn't actually isn't running.

Even though the message says this...

The database server returned this error [...]

...the message is deceptive. What's actually happening is the database connector on the PHP side returned that error.

If this were a permissions error, you would see something like this:

SQLSTATE[28000] [1045]: Access denied for user 'foo'@'localhost' (using password: YES)

Although it does not seem like a permissions error per se, confirm bullet points 1 and 3 from Carlos's response: port is open on server and accessible, and/or change your connection URL to if MySQL is treating your PHP app's request as TCP/IP from the outside.

Failing that, I would triple check the port and URL in the app's connection setup, if the last sentence of your first paragraph states that other PHP apps are working fine over this same database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.