Solved

Unknown MySQL server host 'localhost' (11001)

Posted on 2013-06-13
4
6,402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

632 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