Proudly Hosting over 100,000 Fast Websites since 2010

How to Resolve MAMP’s “Localhost Refused to Connect” Error

How to Resolve MAMP’s “Localhost Refused to Connect” Error

Trying to access localhost on your MAMP server but getting the frustrating “Localhost refused to connect” error? This is a common issue faced by developers using MAMP on Mac to run WordPress or other PHP apps locally. But don’t worry – the localhost connection failure can usually be fixed with a few troubleshooting steps.

In this guide, we’ll walk you through the top 10 ways to troubleshoot and resolve the “Localhost refused to connect” message in MAMP. We’ll go through steps like checking Apache/MySQL status, port conflicts, hosts file edits, DNS flushes, AllowOverride fixes, log checks, reinstalls, and more.

By the end, you should be able to fully restore access to localhost on port 8888 and get your local web development environment running smoothly again.

Check if Apache and MySQL Servers are Running

The first thing you should do when encountering the “Localhost refused to connect” error in MAMP is to check if both the Apache and MySQL servers are up and running. Sometimes one or both of these services fail to start which would cause this error.

Open the MAMP application and check the status indicators next to the Apache and MySQL labels. If either one is not green and running, try restarting both services by clicking the “Start Servers” button.

Once restarted, refresh the page and see if the localhost starts working. A stopped service like Apache or MySQL is the most common reason behind a failed localhost connection.

Look For Port Conflicts

If the MAMP servers show as running but you still can’t access localhost, there may be something already bound to the default MAMP ports. The common HTTP port used by MAMP’s Apache server is 8888 while MySQL uses port 8889 by default.

Open Terminal and execute this command to find out what application could be conflicting on those ports:

sudo lsof -i :8888

If some other application has occupied port 8888, you will need to either quit that application or reconfigure MAMP to use different ports instead. The same check can also be done for port 8889. Restart MAMP afterward.

Check Your Host File

The /etc/hosts file acts as a local DNS resolution system in macOS and Linux. If this file gets corrupted, it can prevent access to localhost in MAMP.

Open the host file in an editor like Sublime Text. Look for an entry like “ localhost”. If this line is missing or altered incorrectly, restore it to the correct format. Also, check for duplicate entries of localhost or

Save the changes after fixing the host’s file and try MAMP’s localhost again. Web access should be restored.

Disable IPv6

In some cases, having IPv6 enabled can interfere with accessing localhost in MAMP. The best way to rule out an IPv6 misconfiguration is to temporarily disable it.

Go to System Preferences > Network. Choose your primary network connection and click the gear icon. Go to Configure IPv6 and set it to “Link-local only”. Confirm to disable full IPv6 support.

Try connecting to http://localhost:8888/ now and check if the problem has gone away. Re-enable IPv6 afterward if this fixed MAMP.

Flush DNS Cache on macOS

A corrupted DNS cache on your Mac could also be the culprit behind “Localhost refused to connect” errors. Flushing it removes any bad DNS records stored on your system.

On macOS, you can flush DNS by executing this one-line Terminal command:

sudo killall -HUP mDNSResponder

Now restart the MAMP application and it should be able to resolve localhost correctly again.

Edit AllowOverride Directive

By default, MAMP uses Apache’s .htaccess files for its configuration. But .htaccess rules require the AllowOverride directive to be enabled in httpd.conf first.

Check inside MAMP’s httpd.conf file and make sure that this line exists with the correct value:

AllowOverride All

On saving changes and restarting MAMP, localhost access issues originating from incorrect overrides will be fixed.

Look for Errors in Log Files

For serious connection issues with localhost, inspecting Apache and MySQL logs could provide clues to narrow down the problem.

The Apache access, error, and general logs can be found inside MAMP’s logs folder. Similarly, for MySQL logs check inside MAMP’s db/mysql folder.

Open the latest log files and scan for specific error messages like “Connection refused”, “Timeout”, “Address already in use”, etc. These messages will tell you exactly why localhost is not working.

Reinstall or Update MAMP

If no solutions have helped resolve the localhost connection error so far, there might be an underlying problem with your MAMP installation itself.

Try downloading and installing the latest version of MAMP available from their website. Before installing, ensure you have fully uninstalled the existing copy via the AppCleaner tool.

Reconfigure MAMP to the same PHP versions and ports after reinstalling. Then test if the localhost starts working again.

Reset MAMP to Default Configuration

If a reinstall didn’t help either, the next option is to strip down the configuration of your existing MAMP to eliminate any bad settings.

First stop MAMP’s servers. Then go to Preferences > General and click the “Reset Configuration to Defaults” button. This will redo all ports, document roots, and other settings to the factory state.

Attempt connecting to localhost again. If the reset configuration forces MAMP to work properly again, then one of your customized settings must have been causing issues.

Contact Customer Support

As a last resort when all else has failed, get in touch with MAMP’s customer support. Explain the diagnostics and fixes you have attempted so far. Include saved log files showing exact error messages.

The MAMP support team may be able to identify issues in the configuration that you couldn’t figure out yourself. Or escalate known bugs that might be causing localhost to not work properly in your environment.

Hopefully, with their help, the “Localhost refused to connect” error in MAMP can finally be put to rest!


In conclusion, the “Localhost refused to connect” error doesn’t mean your MAMP setup is doomed.

In almost all cases, the localhost connection issue can be rectified with systematic debugging using the solutions discussed here. Check logs, ports, overrides, DNS, and configuration errors to identify the culprit.

Get in touch with MAMP support if you have tried everything. With some targeted troubleshooting, you should see your local web projects opening happily again!


Leave a Reply

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