A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

A connection attempt failed error

It looks on windows php5.3 has some kind of confusion on localhost :)

I have been using the earlier version without any problem and the moment I update to the newer version.

I got error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

As a remedy, just change the localhost with 127.0.0.1 and it will work like a charm…

Prev –

mysql_connect('localhost', 'root', 'root'); 

To

mysql_connect('127.0.0.1', 'root', 'root'); 

Click here to See how you can upgrade mysql

While you are here, I would recommend for you:

Do you know how to add scroll bar to mysql terminal?

How I setup LAMP on AWS step by step

Learn nodeJs with AngularJS in a complete project step by step

See how you would solve these known algorithm problems

Flatten nested javascript array

binary tree problems with solution

Find the pairs that makes K Complementary in the given array java solution

Find longest palindrom from sequence of characters

Check if two strings are anagrams or not

Kadane’s algorithm in C – Dynamic Programming

Java solution for checking anagram strings – tell if phrases are anagrams

Find the first occurence of number in the sorted array

Changing decimal number to its binary equivalent

find longest word in the sentence

9 Comments
  1. Robert

    Your a lifesaver I have been racking my brain trying to get this working I knew it all worked fine with earlier versions and before trying your trick of replacing localhost with 127.0.0.1 I was about to go back to the earlier versions which I really didn’t want to do. Now all the mysql, mysqli and PHPMyAdmin works great. Thanks a ton.

  2. gullele

    Thanks Robert, I am glad it helped you.

  3. Chris Atkins

    Thanks – I stumbled across your answer completely by chance via Google, but it fixed my problem instantly where several other answers had failed.:-)

  4. gullele

    Thanks Atkins, I am happy that it worked for you.

  5. Ron

    The problem as it turns out, is a bug in MySQL, not PHP. I just ran into it today. Everyone should use the fix of changing their scripts to use 127.0.0.1 rather than edit the hosts file to disable IPv6 support for localhost.

    1. gullele

      Thanks Ron, yea, this would be a nice short cut rather that messing with the hosts.

  6. Yakov

    I am so happy I found this solution. I was pulling my hair over it. Thanks!

    1. gullele

      Thanks too Yakov, I am happy that it helped you

  7. Yair

    Thanks. It seems a php issue (I have 5.2.9)

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*