FG

MySQL localhost connect works but 127.0.0.1 does not

Fresh3 days ago
Mar 15, 20266127 views
Confidence Score0%
0%

Problem

Does anyone know what the error could be when I can connect to my MySQL server via localhost but not via 127.0.0.1? AFAIK, these should be routed identically and no additional TCP layer should be created when using the IP. The table permissions are explicitly set to include both methods.

Error Output

$ mysql -u root -h localhost -D test # works
$ mysql -u root -h 127.0.0.1 -D test # does not work
(127.0.0.1 does map to localhost/vice versa)

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: MySQL localhost connect works but 127.0.0.1 does not

Low Risk

The MySQL client library overrides localhost to use a Unix socket instead of a TCP/IP connection to 127.0.0.1. If you can connect to localhost but not 127.0.0.1, that suggests that it's either firewalled or not listening on 127.0.0.1.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment