Speed issues with WordPress on MAMP when accessing a local MySQL database

I’m facing a frustrating problem while working on my local web development. I’m using MAMP on my laptop for running WordPress and trying to connect it to an external MySQL database that resides on my main desktop, which is just a meter away on the same local network via WiFi.

The loading times for WordPress are incredibly slow, taking up to 5-10 seconds for requests when I attempt to access this external database at the IP 192.168.1.60:8889. To make matters more confusing:

  1. Switching to MAMP’s internal database results in fast performance.
  2. Other PHP applications using the same external MySQL server respond quickly without issues.
  3. Even when I connect WordPress to a MySQL server situated far away over the internet, it works surprisingly fast!

It seems that the problem lies only with the combination of WordPress, MAMP, and the external MySQL database on my local network. Has anyone else dealt with a similar issue? I suspect there could be a misconfiguration in MAMP’s MySQL settings or something else causing this lag.

Had this exact problem last year with multiple WordPress sites. MAMP’s MySQL timeout settings were way too low for external connections, plus WordPress was doing tons of reverse DNS lookups that kept timing out. Fixed it by editing the my.cnf file in MAMP’s MySQL config folder - bumped connect_timeout and wait_timeout to 28800. Also had to disable skip-name-resolve since it was making WordPress hang during login. Other PHP apps don’t have this issue because they don’t do the same database validation checks WordPress runs on every request. Internet connections work faster because they skip your local network’s DNS caching problems that mess with MAMP’s resolver.

Check your firewall settings - I had the same slowdowns when my MacBook’s firewall was inspecting every MySQL packet. Try switching from port 8889 to 3306 too. MAMP gets weird with non-standard ports on external connections. Test with telnet first to see actual connection speeds before WordPress muddles things up.

Classic DNS resolution issue - I’ve hit this with MAMP before. WordPress is probably trying to reverse-lookup the hostname when you connect to 192.168.1.60:8889, which kills performance on local networks. Add an entry to your hosts file mapping that IP to a hostname, or use localhost with SSH tunneling if your desktop supports it. Could also be that MAMP’s MySQL client uses different connection methods (socket vs TCP) for external vs internal connections. Check your wp-config.php and set ‘DB_HOST’ to ‘192.168.1.60:8889’ with explicit TCP connection parameters. I had the same slow performance until I forced TCP connections and skipped hostname resolution entirely.