Solved

Unknown MySQL server host 'localhost' (11001)

Posted on 2013-06-13
4
5,833 Views
Last Modified: 2013-06-13
Hi, I have a mysql database application with a PHP font end.

Suddenly I am now getting the following error in my web browser when I access a page which includes a mysql connection:

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'localhost' (11001) in <path on local hard drive> on line 13
 Could not conneft to MySQL: Unknown MySQL server host 'localhost' (11001)

When I first access the application it all works fine but after about a dozen clicks (accessing of different pages/records) I locks up and I get the error.

When I try to connect the MySQL using the query browser I get the error:

Could not connect to the specified instance. MySQL Error Number 2005
Unknown MySQL server host 'locolhost' (110001)

When I ping localhost from the MySQL Query Browser I get "unable to resolve localhost" but I can still access the first web page in my browser which does not use a mysql connection so the localhost name is still resolved.

To add to this it will all suddenly start working again after about 5 -10 minutes. It's as if the connection cuts in and out!

Any help appreciated. Thank you.
0
Comment
Question by:EICT
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:BurundiLapp
ID: 39244049
What platform is this running on, can you monitor the MySQL service to see if it is going offline after a few requests and then restarting itself?

Anything in the MySQL or the OS event logs to indicate an issue?  Are you logging PHP errors to a file, if so anything in there to indicate an issue?
0
 

Author Comment

by:EICT
ID: 39244098
Hi BurundiLapp
I shall investigate more and get back to you.  Interestingly if I change localhost in the mysql_connection script to the IP address 127.0.0.1 it works. Change it back to localhost  and it stops again. It's as if mysql/php can't resolve localhost  because I can still ping it etc in a command prompt.  

I'm running Win 7.   I can't see any services stopping/starting. I tried restarting mysql & apache services in services.msc which did not appear to fix the problem.  Restarting my DNS-client services seems to be the fix. So it must be to do with DNS.
0
 
LVL 6

Accepted Solution

by:
BurundiLapp earned 500 total points
ID: 39244104
It could also be related to IPV6 and DNS, I would also turn off IPV6 on that box if you are not using it.

Is there any reason you can't leave it configured as the IP to ensure there is no re-occurence?
0
 

Author Comment

by:EICT
ID: 39244132
I logged DNS errors and was getting "A name not found error was returned for the name localhost. Check to ensure that the name is correct. The response was sent by the server at 213.120.234.6:53."   for some reason the BT DNS could not resolve it. Having said that I thought the PC resolved localhost itself.

You were spot on. I disabled IPv6 and it works now.   Strange why this suddenly started.

Thanks BurundiLapp
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to stop user from going back to a previous page in PHP 3 31
php string detection problem 7 33
AWS EC2 & RDS Instance 5 34
PHP not parsing ' character 12 38
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question