Can’t connect to MySQL server on ‘’ (61) on Mac

Hard drive with its case removed.
Because data is stored on hard drives.

I downloaded the MySQL server and installed it on my Mac, but every time I tried to connect to it, I got the following error:

Can’t connect to MySQL server on ‘’ (61)

There can be many reasons for this error, most of which are generously covered online, but in my case it was because MySQL was running on port 3307.

I think the port was updated in a recent MySQL server update, because I’ve never had this issue with a previous MySQL server version.

Here’s how to check if you have the same problem, and how to change it to port 3306 (unless you want to keep it running on port 3307).

Make sure MySQL server is running

Screenshot of MySQL preference pane on Mac showing that MySQL server is running.
MySQL Preference Pane

Confirm MySQL server is listening on port 3307

Run this command in Terminal:

$ sudo lsof -i -P | grep -i mysqld
mysqld  51211  _mysql  ...  0t0  TCP *:3307 (LISTEN)
mysqld  51211  _mysql  ...  0t0  TCP localhost:3307->localhost:54348 (ESTABLISHED)
mysqld  51211  _mysql  ...  0t0  TCP localhost:3307->localhost:54350 (ESTABLISHED)

Here’s what it means:

  • sudo — Run as root, so we can see everything that’s running, not just under the current username.
  • lsof — Display information about files open to Unix process.
  • -i — List all internet and x.25 (HP-UX) network files.
  • -P — Inhibit conversion of port numbers to port names.
  • grep mysqld — Display only lines matching mysqld.

As you can see, the MySQL server is running on port 3307. If that’s your problem, read on, but if not, I don’t think this post will address your issue.

Confirm port setting in property list (plist)

It turns out that this configuration file is the culprit:

$ defaults read /Library/LaunchDaemons/

You can see the port setting on line 18:

  Disabled = 0;
  ExitTimeOut = 600;
  GroupName = "_mysql";
  KeepAlive = 0;
  Label = "";
  LaunchOnlyOnce = 0;
  ProcessType = Interactive;
  Program = "/usr/local/mysql/bin/mysqld";
  ProgramArguments =     (
  RunAtLoad = 0;
  SessionCreate = 1;
  UserName = "_mysql";
  WorkingDirectory = "/usr/local/mysql";

Update port number from 3307 to 3306

Stop the MySQL server and make a backup of the current plist:

$ sudo cp /Library/LaunchDaemons/ /Library/LaunchDaemons/

Convert the plist to XML so you can easily edit it:

$ sudo plutil -convert xml1 /Library/LaunchDaemons/

Edit the file and replace the port with 3306:

$ sudo vi /Library/LaunchDaemons/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

You can quickly jump to the port by typing: /3307 and hitting ENTER. Switch to edit mode with: i. Save file with: ESC and :wq!.

Convert the plist back to binary:

$ sudo plutil -convert binary1 /Library/LaunchDaemons/

Start MySQL server and confirm port 3306

This should be all there is to it. Confirm that the MySQL server is running on port 3306 with the same command we used earlier:

$ sudo lsof -i -P | grep -i mysqld

It took me a little while to figure this out, but hopefully this post will save you some troubleshooting time.

Featured image by Art Wall.

Comments (11)

Previously posted in WordPress and transferred to Ghost.

September 20, 2015 at 4:19 pm

Thank you! You saved my Sunday afternoon!

October 2, 2015 at 3:49 am

Thank you! That is an excellent fix. Stupid changing plist file!

October 19, 2015 at 8:29 pm

Thanks a lotttttttt!!!!
You have no idea how grateful I am!!!

January 22, 2017 at 8:17 pm

Good one. Had issues for a while but never imagined its something to do with the port on my mac. Thanks

March 2, 2017 at 9:03 pm

mysql can’t start also if ram and drive space is full too used… so i need to make swap for ram, and deleting the unnecessary files or folder to make it free space, the mysql will be starting again

Roll the ball
May 9, 2018 at 3:36 am

That is an excellent fix. thank you :))

happy wheels
June 23, 2018 at 4:21 am

I do have a user and group apache, and apache runs as apache. Any ideas?

July 23, 2018 at 5:36 am

Domain /Library/LaunchDaemons/ does not exist

April 26, 2019 at 8:56 pm

line 18 I can’t find the port no.

July 17, 2019 at 10:23 pm

When I run this command:
sudo lsof -i -P | grep -i mysqld

I get a prompt to enter a password. I enter my mySQL password and nothing happens.

October 31, 2020 at 12:14 pm

It’s *not* asking for your MySQL password. It’s asking for your operating system’s administrative password.