How to solve PHP Warning: mysqli_connect(): (HY000/2002): Connection refused problem?

The default port on MAMP for mysql is 8889, but the port that php expects to use for mysql is 3306. So you need to change it. Open MAMP, go to Preferences and Ports and change the MAMP mysql port to 3306, then click ok. Then mysql server will be restarted by MAMP if not then restart it manually. Now the connection should be successful with host=localhost, user=root, pass=root.

Hope it helps. If yes then don’t forget to comment below thanks.

About the Author

has written 34 stories on this site.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

*