MAMP "Apache cannot be started because the port is in use." And "Can't connect to local MySQL server via / tmp / mysql.sock

After restarting MAMP, I noticed that the MySQL Server checkbox did not turn green as usual. I clicked "Start Servers" again and got a message that "Apache cannot be started because port 8888 is in use by other software." Strange as I haven't made any changes to the system or app or installed any updates. I opened Chrome and entered the url of a site I am developing locally and it showed up without issue. But when I tried to log into the site with a dummy user account, I got "SQLSTATE [HY000] [2002]. Can't connect to local MySQL server via socket" /Applications/MAMP/tmp/mysql/mysql.sock ", (2 ) ".

As for the first problem (Apache port is in use by another program), I opened a terminal and >> sudo lsof -i -P | grep -i "listen"

to see what ports would be displayed. When MAMP was closed, the console output was

launchd 1 root 23u IPv6 0x156733646a84db9h 0t0 TCP *:5900 (LISTEN) launchd 1 root 24u IPv4 0x156733646a84eba8 0t0 TCP *:5900 (LISTEN) launchd 1 root 28u IPv6 0x156733646a84d75u 0t0 TCP localhost:631 (LISTEN) launchd 1 root 29u IPv4 0x156733646a84e3bu 0t0 TCP localhost:631 (LISTEN) launchd 1 root 31u IPv6 0x156733646a84d31u 0t0 TCP *:22 (LISTEN) launchd 1 root 32u IPv4 0x156733646a857ba5 0t0 TCP *:22 (LISTEN) kdc 96 root 6u IPv6 0x156733646a84cedt 0t0 TCP *:88 (LISTEN) kdc 96 root 8u IPv4 0x156733646c2a9ba5 0t0 TCP *:88 (LISTEN) imagent 270 userhomedirectory 7u IPv4 0x156733646a1a13bb 0t0 TCP *:52216 (LISTEN) EEventMan 279 userhomedirectory 4u IPv4 0x156733646a8573bb 0t0 TCP *:2968 (LISTEN)

Output when MAMP (all of the above) + is executed:

httpd 28772 userhomedirectory 5u IPv6 0x156733646a84b55f 0t0 TCP *:8888 (LISTEN) httpd 28786 userhomedirectory 5u IPv6 0x156733646a84b55f 0t0 TCP *:8888 (LISTEN) httpd 28790 userhomedirectory 5u IPv6 0x156733646a84b55f 0t0 TCP *:8888 (LISTEN) httpd 28791 userhomedirectory 5u IPv6 0x156733646a84b55f 0t0 TCP *:8888 (LISTEN) httpd 28792 userhomedirectory 5u IPv6 0x156733646a84b55f 0t0 TCP *:8888 (LISTEN) httpd 28793 userhomedirectory 5u IPv6 0x156733646a84b55f 0t0 TCP *:8888 (LISTEN) httpd 28794 userhomedirectory 5u IPv6 0x169041156a84b55f 0t0 TCP *:8888 (LISTEN)

So, port 8888 is only used when starting MAMP, which also tells me that the webserver is actually connected. So I don't understand why I am getting Apache port error.

Anyway, then I opened Activity Monitor and killed every HTTPd and mysqld process that was running and restarted MAMP, but the problem persisted. The mysqld process never showed up after I killed it the first time.

Then I searched SO. I came across a post regarding MAMP PRO and decided to try the suggested solutions, but to no avail. The same goes for this post 's suggestion to uninstall and reinstall the entire app.

So far, I cannot determine if the mysql error is causing the apache error or the apache error is causing the mysql error. So, I've searched and tried several solutions regarding the mysql error, including the suggestions from this post , and this post , but none of them worked for me. I mean, I've literally tried every suggestion on these pages, from the posted responses to comments.

I also tried rebooting my computer by changing the apache, nginx and mysql port config options, switching from apache to nginx, loading MAMP MySql from terminal, creating a my.cnf file with socket config. None of them worked.

Does anyone have any experience? Is this an Apache port bug or a MySQL socket bug? Or something completely different? And given that there were no updates or changes to anything in the system or application, what could have caused this?

Thanks in advance.

* ** Edit Dec 10, 2014 ***
So I played with this all night. I have re-installed the app several times. Installed some updates and even copied my laptop MAMP setup that works to my desktop. But I still got the same errors. Then I replaced the root of the MAMP document with the default Mac HD -> Applications -> MAMP -> htdocs

and it works! I previously installed it on /Users/userhomedirectory/Sites

.

I posted this as an edit instead of an answer because the problem still exists. Changing the document root back to Users/myhomedirectory/Sites

gives me the same error messages as before, so my solution is a more workaround. Hopefully this caused a lightbulb for someone, because I still can't figure out what might be the cause and / or solution.

+3


source to share


8 answers


I don't know if this will help anyone ... but this worked for me:

sudo apachectl stop

: -)



from fooobar.com/questions/110330 / ...

+17


source


I faced the same issue after upgrading to yosemite and MAMP version 3.0.7.3. Tried many suggestions and fixed there but none of them worked for me.

When he hit me! On clicking "Set Web & MySQL ports to 80 and 3306" in MAMP, MAMP sets port 80 for Apache AND Nginx. The result is an error since both are set to use the same port. I just installed Nginx on a different random port, clicked OK and there was no error.

I have restarted Apache and MySQL. And voila!



All my local sites are working the same as before the update.

Luckily, I just read an interesting article explaining how to configure Nginx in front of Apache to provide static and dynamic independently to optimize performance. This sparked this thought.

Hope this helps!

+3


source


Go to MAMP config and change the port address 8888

to any other address

MAMP->Preferences->Ports->Apache Port

      

I think it will work fine

+2


source


Like Nathan Rutman, this turned out to be a problem for me. I was getting the same errors as above - Apache couldn't be started because port 8888 is in use by some other software.

... and MySQL Server would not start.

I have no luck changing ports or moving directory in htaccess.

What worked:

I went to Applications

, selected MAMP

and created a Finder dialog Get Info

. I added permissions Read & Write

for the current user and admins, clicked the gear and clickedApply to enclosed items...

I did the same for MAMP Pro to make sure my bases were closed.

Launched MAMP, changed ports to standard and booms! Everything works, including MySQL Server - no terminal commands.

This kept working when I changed directory to folder again /Users/myuser/Sites/

.

+1


source


UPDATE:

In fact, this is just a permissions issue. I faced the same problem again and just did chown -R nathan:staff <dir>

and restarted Apache in MAMP. It worked fine.

ORIGINAL MAIL:

Oddly enough, I think I fixed the problem on my machine. After examining the directories for both the default htdocs directory and the directory I wanted to use, I noticed that the default directory was owned nrutman:admin

and the directory I wanted to use was owned by nrutman:staff

(same user, different group).

Through the Finder Info panel (Cmd-I), I added read / write permission for the group Administrators

to the folder and removed the permission of the staff group. I restarted MAMP and it worked! Then, after chown

, I changed the owner to nrutman:staff

. The Finder information panel now looked the same as before, but now MAMP will use this directory without complaining about ports.

Definitely seems to be a MAMP bug. Not really sure what's going on, but I hope this helps others who are struggling with this issue.

0


source


I was able to change the Nginx port.

0


source


If the MySQL instance is not running, this is probably a permission issue. Right click the icon -> run as administrator

.

0


source


I don't mean this is trivial, but when it happened to me, I started trying some suggestions here (permissions, etc.), but when I just restarted my computer it worked after that. So just a reminder to try restarting before others try.

0


source







All Articles