TechBuzzPro

Change MAMP to Default Apache and MySQL Ports

· 6 min read · Apps & Browsers

In this article
  1. Why MAMP Uses Port 8888 and 8889 by Default
  2. How to Change the Ports in MAMP
  3. What If Port 80 or 3306 Is Already in Use?
  4. How to Verify the Ports Are Working
  5. Common Problems and Misconceptions
  6. Comparing MAMP Ports with Other Local Development Stacks
  7. Frequently Asked Questions

To change MAMP back to the default Apache (port 80) and MySQL (port 3306) ports, open MAMP’s Preferences, go to the Ports tab, click “Set to default Apache and MySQL ports,” and restart MAMP. This article explains why MAMP uses non-standard ports, how the change works, what to do if the ports are already in use, and common pitfalls you may encounter.

Why MAMP Uses Port 8888 and 8889 by Default

MAMP (Macintosh Apache MySQL PHP) is a local development environment that bundles Apache, MySQL, and PHP for macOS and Windows. Out of the box, MAMP configures Apache to listen on port 8888 and MySQL on port 8889 instead of the standard ports 80 and 3306. The reason is simple: those standard ports are often already occupied by system services. On macOS, for example, the built-in Apache web server may be running on port 80, and MySQL may already be installed as a system service on port 3306. Using alternate ports lets MAMP run side-by-side with existing software without conflicts.

When you switch to the default ports, you are telling MAMP to use the same ports that a production web server would use. This makes your local URLs look like http://localhost instead of http://localhost:8888, and your MySQL connections use the default port 3306, which many applications expect.

How to Change the Ports in MAMP

The process is the same in MAMP 4, MAMP 5, and MAMP 6 (the current major version as of 2024). Follow these steps:

  1. Quit MAMP completely (Cmd+Q on Mac, or close the window on Windows).
  2. Open MAMP again. The MAMP start page should appear in your browser.
  3. In the MAMP application window, click the “Preferences” icon (the gear or sliders icon).
  4. Click the “Ports” tab.
  5. Click the button labeled “Set to default Apache and MySQL ports.” This will change the Apache port to 80 and the MySQL port to 3306.
  6. Click “OK” to save the changes.
  7. Restart MAMP by clicking “Stop Servers” and then “Start Servers.”

After the restart, your local sites will be available at http://localhost (or http://127.0.0.1) without a port number. MySQL connections will use port 3306 by default.

What If Port 80 or 3306 Is Already in Use?

If the default ports are already occupied, MAMP will fail to start Apache or MySQL, and you may see an error message in the MAMP log files. The most common culprits are:

  • macOS built-in Apache: macOS ships with Apache pre-installed and sometimes running. You can stop it with sudo apachectl stop in Terminal, or disable it entirely with sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist.
  • A system-installed MySQL: If you have MySQL installed via Homebrew or the official installer, it may be running on port 3306. Stop it with brew services stop mysql or sudo service mysql stop (Linux/Windows).
  • Skype or other applications: Some applications (like older versions of Skype) used port 80 for incoming connections. Check your application settings and disable that feature.
  • Windows IIS or World Wide Web Publishing Service: On Windows, IIS may occupy port 80. You can stop it via Services (services.msc) or change its bindings.

To see what is using a port, use lsof -i :80 on macOS/Linux, or netstat -ano | findstr :80 on Windows. The output will show the process ID (PID) of the program using that port.

How to Verify the Ports Are Working

After changing the ports and restarting MAMP, you should verify that everything is running correctly:

  • Open your browser and go to http://localhost. You should see the MAMP start page (or your own site if you have set a document root).
  • Open the MAMP application window. The status indicators for Apache and MySQL should be green.
  • Check the MAMP log files (usually in /Applications/MAMP/logs/ on Mac, or C:\MAMP\logs\ on Windows) for any errors.
  • Test MySQL from the command line: mysql -u root -p -h 127.0.0.1 -P 3306. If you can connect, the port is correct.

If you see a “connection refused” error, the port may still be occupied, or the MySQL service may not have started. Check the logs for more details.

Common Problems and Misconceptions

One common misconception is that changing the ports in MAMP will automatically update your PHP scripts or database connection strings. It will not. If your application hard-codes the port (for example, mysqli_connect('localhost:8889', ...)), you will need to update that code to use the new port or remove the port entirely so it uses the default.

Another issue is that MAMP’s “Set to default” button may not work if the ports are already in use. In that case, you must free the ports first, as described above. Some users also report that after changing ports, their existing virtual hosts stop working. This is usually because the virtual host configuration references the old port. You can fix this by editing the httpd.conf file or the included virtual hosts file (often /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf on Mac).

If you are using MAMP Pro, the process is slightly different: you change the ports in the “Ports” section of the MAMP Pro interface, and you may also need to adjust the “General” tab settings. MAMP Pro also allows you to set different ports for each virtual host, which can be useful for testing multiple sites.

Comparing MAMP Ports with Other Local Development Stacks

Other local development environments handle ports differently:

  • XAMPP uses port 80 for Apache and 3306 for MySQL by default, but it also provides a control panel where you can change them if needed.
  • Laravel Valet (macOS) uses port 80 and runs through the system’s built-in Apache or nginx, so it always uses the default port.
  • Docker containers can map any host port to any container port. For example, you can map host port 8080 to container port 80.
  • WampServer (Windows) uses port 80 by default, but it also has a “Put Online” feature that can conflict with IIS.

Using the default ports makes your local environment more similar to a production server, which can help avoid “works on my machine” issues. However, it also requires that no other service is using those ports.

Frequently Asked Questions

Why does MAMP use port 8888 instead of 80?

MAMP uses port 8888 to avoid conflicts with the built-in Apache web server that macOS runs on port 80. By using a non-standard port, MAMP can run alongside the system Apache without requiring you to stop it. This is convenient for beginners but can be confusing when you expect to access your site at http://localhost.

Will changing the ports affect my existing databases?

No. Changing the MySQL port does not affect the data in your databases. Your data files remain in the MAMP db directory (usually /Applications/MAMP/db/mysql on Mac). However, any application that connects to MySQL must use the new port. If you have scripts with hard-coded port numbers, update them.

Can I set Apache to port 80 but keep MySQL on 8889?

Yes. In the Ports tab, you can manually enter the port numbers you want. For example, set Apache to 80 and leave MySQL at 8889. This is useful if you have another MySQL instance on port 3306 that you want to keep running.

What if I get a “port already in use” error after clicking “Set to default”?

That means another program is using port 80 or 3306. You need to stop that program first. On macOS, check if the built-in Apache is running with sudo lsof -i :80. On Windows, check for IIS or Skype. Once the port is free, restart MAMP.

Do I need to change my browser bookmarks after switching ports?

Yes. If you bookmarked http://localhost:8888, you will need to update it to http://localhost. The same applies to any links in your code or documentation that include the port number.

Is it safe to use port 80 for local development?

Yes, it is safe on your own machine. Port 80 is the standard HTTP port, and using it locally does not expose your development server to the internet unless you have port forwarding enabled on your router. Just be aware that some security software may flag local web servers, but that is rare.