If you’re like me, using EasyPHP on Windows 7 for local development and have encountered this PHP/MySQL error:
Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Path\To\Script.php on line 26 Warning: mysql_connect() [function.mysql-connect]: 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. in C:\Path\To\Script.php on line 26 Fatal error: Maximum execution time of 30 seconds exceeded in C:\Path\To\Script.php on line 26
..then you’re in luck! Here’s a quick easy fix:
- Go to “C:\Windows\System32\drivers\etc“.
- Open “hosts” with Notepad program.
- Uncomment this line: “127.0.0.1 localhost” or add it if it’s not on the host entry.
That’s it! Save the changes you’ve made and refresh your browser.
Hope this helps!
* NOTE - Make sure you have a full access on “hosts” file.
- Right click on “hosts” file then click “Properties“.
- On “Security” tab click “Edit…” button.
- Select the user that you are currently using.
- Under “Permissions for Users” box, tick “Full control” on “Allow” column.
- And then click “OK” button to apply the changes.






