Cannot connect to a fresh brew install of mysql from a client on the same host

Abstract: Resolve MySQL connection failures on macOS by fixing IPv6 binding issues and specifying the correct Unix socket path in client configuration.

Created: 2026-10-23 by

When a fresh Homebrew MySQL installation fails to accept local connections, the issue is typically caused by the server binding exclusively to IPv6 or running under a different user context that restricts socket permissions. Verify the network configuration and ensure the client uses the correct Unix socket path located in /tmp or /usr/local/var/mysql.

Understanding the Localhost Binding Behavior

MySQL on macOS installations managed by Homebrew often defaults to binding to the loopback interface. However, modern versions may prioritize IPv6 addresses for localhost connections. If your client attempts to connect via 127.0.0.1 but the server is only listening on ::1, the connection will fail silently or with a timeout error. This discrepancy is common in environments where network stacks handle IPv4 and IPv6 differently. You must confirm which address family the server is actually accepting connections on before troubleshooting permission issues.

Checking Network Bindings

To determine if the server is listening correctly, you can inspect the active ports. Use the lsof command to list open files associated with the MySQL process. Specifically, look for entries related to TCP ports 3306. If you see IPv6 listed instead of IPv4, this confirms the binding preference. The output should show the server PID and the specific address it is bound to. This diagnostic step helps isolate whether the problem is network-level or authentication-related.

Verifying Socket Permissions and Paths

The most frequent cause of connection failures on a fresh install is an incorrect Unix socket path. MySQL clients default to looking for a socket file in /tmp/mysql.sock or /var/mysql/mysql.sock. Homebrew, however, often places this file in /tmp/mysql.sock or within the Cellar directory depending on the version. If the client cannot find the socket, it throws a "Can't connect to local MySQL server through socket" error. You need to locate the actual socket file created by the service.
  1. Start the MySQL service using brew services start mysql.
  2. Run ls -l /tmp/mysql.sock to check existence.
  3. If missing, check /usr/local/var/mysql/ for any .sock files.
  4. Specify the correct path in your client command using --socket.
This manual specification bypasses the default search path and forces the client to use the correct endpoint. It is a quick fix that validates whether the server is running and accessible at all.

Adjusting Client Configuration

You can make this change permanent by editing your my.cnf file. Add the [client] section and define the socket variable pointing to the correct location. This ensures that all future client commands, including those from scripts, use the right path without manual intervention. Without this configuration, every new terminal session might require explicit socket arguments.

Addressing User Context and Permissions

Homebrew runs services under your current user account by default, unlike system-wide installations that run as _mysql. This difference affects file permissions significantly. If you installed MySQL using a different user or switched accounts, the socket file might be owned by a user who lacks read/write access for the current shell. Additionally, firewall settings on macOS can block incoming connections even if they are local. While less common for localhost traffic, it is worth verifying that no security software is intercepting the loopback interface.

Restarting Services Correctly

After making changes to configuration files, you must restart the service for them to take effect. Use brew services restart mysql to apply new bindings or socket paths. Failure to restart often leads to confusion where the old configuration remains active. Always check the logs in /usr/local/var/mysql/ for errors during startup. These logs provide detailed information about why the server might have refused connections or failed to bind to the expected address.

Troubleshooting Authentication Issues

If the network and socket paths are correct, the next hurdle is authentication. Fresh installs often create a root user with auth_socket plugin, which allows login only via Unix socket and requires matching OS user credentials. If you try to connect with a password, it will fail because the socket method ignores passwords. Conversely, if you switch to password authentication, you must set a password first. Understanding this distinction prevents unnecessary network debugging when the issue is purely credential-based. Fixing Perl Dependency Error During MySQL Installation on Rocky Linux 9.4 in Oracle VirtualBox discusses similar installation pitfalls regarding dependencies, though on a different OS. While the platform differs, the principle of verifying installation integrity applies here as well. Ensuring that all underlying components are correctly configured prevents cascading failures.

Ensuring Service Persistence

A fresh install might not persist across reboots if not properly configured. Homebrew provides a launch agent setup that handles this automatically. Ensure that brew services start mysql was executed successfully. If the service stops unexpectedly, check the console logs for crash reports. Persistent connectivity requires the daemon to remain active and responsive to local requests. SQL Server Access Linux SQLCMD: Login Timeout Expired, TCP Provider: Error Code 0x2AF9 highlights timeout issues in database connections. Although unrelated to MySQL, the concept of timeouts applies when servers are unresponsive due to configuration errors. Recognizing timeout symptoms helps distinguish between network blocks and server-side failures.

Frequently Asked Questions

Why does my MySQL client fail with a timeout error?

This usually indicates that the server is not listening on the IP address your client is targeting. Check if MySQL is bound to IPv6 while your client uses IPv4, or verify that the service is actually running. Adjusting the bind-address in my.cnf can resolve this mismatch.

How do I find the correct Unix socket path?

Use the find command to search for *.sock files in your Homebrew prefix or /tmp. Alternatively, query the running MySQL instance using mysqladmin variables if you can connect via a known good path. The socket variable in the output reveals the exact location.

Can I connect using 127.0.0.1 instead of localhost?

Yes, specifying 127.0.0.1 forces TCP/IP connection rather than Unix socket usage. This bypasses socket permission issues but requires the server to listen on IPv4. Ensure skip-networking is not enabled in your configuration for this to work.

What causes auth_socket errors after a fresh install?

The root user is often configured to authenticate via the operating system user via socket. This means you cannot log in with a password unless you change the authentication plugin. Switching to mysql_native_password allows standard password-based logins for remote or scripted access.

Is it safe to disable the macOS firewall for MySQL?

Disabling the firewall entirely is not recommended for security reasons. Instead, configure specific exceptions for MySQL ports if remote access is needed. For local connections, the firewall rarely interferes unless third-party security software is present. Test connectivity with the firewall disabled temporarily to isolate the cause.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More