Solved

Unknown MySQL server host 'localhost' (11001)

Posted on 2013-06-13
4
6,210 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with mod_substitute 18 78
PHP Web Development 6 70
How would I break down this array? 3 20
How to convert PHP array into string ? 16 27
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 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