MySQL: Access denied using 127.0.0.1 but OK using localhost.

zhongshan

Member
PartnerNOC
Jan 17, 2008
18
2
53
Hello,

I've recently replaced an older server and after migrating all the accounts I'm having many customers not being able to connect to MySQL using the address '127.0.0.1' but they're being able to connect using 'localhost'. I know I could just allow '%' or even '127.0.0.1' but I would like to find the solution because I'm getting more and more tickets about this and I find it very annoying as localhost and 127.0.0.1 are the same thing.

I'm using:

Server version: 10.3.23-MariaDB-cll-lve MariaDB Server

Thank you
 

zhongshan

Member
PartnerNOC
Jan 17, 2008
18
2
53
Hi, thank you for your reply.

I don't see any relation other than the mention of "Granting User Connections From Remote Hosts" but that's what I don't want to do, I don't want to have to alllow 'everyaccount'@'%'. None of all my servers have that problem, and there are no grants to users with the host '127.0.0.1'.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,304
1,250
313
Houston
The connection I believe is in the bind-address configuration which they discuss there right at the beginning of the article. It does not require grants but is a known issue users experience with MariaDB when attempting to connect over TCP whether using 127.0.0.1 or a different IP. MySQL tries to connect using a socket when you use localhost, but it uses TCP when you connect to 127.0.0.1, and the permissions can even be set differently for localhost and 127.0.0.1, which is why I linked you that specific article.

A quick google search also shows you a number of others with the same questions:

What I linked you looks to be the most relevant information but the articles listed may provide other advice.