Strapi MySQL connector resolves localhost as 127.0.0.1, but should it be?

Hi everyone and thanks for being part of this amazing community !

I’m not sure this discussion is legit, but as it costs nothing, I’m here to debate.

I’m having a deployement issue in production with a hosting provider : they accept, for security policy, only connection using ‘localhost’ as host to connect to MySQL database, and not 127.0.0.1.

The problem is, in my configuration, that I registered my configuration under “localhost”, and it has been resolved to 127.0.0.1 according to this error log :

(…)
[2020-10-27T08:18:39.300Z] error Impossible to register the ‘(…)’ model.
[2020-10-27T08:18:39.300Z] error Error: ER_HOST_NOT_PRIVILEGED: Host ‘127.0.0.1’ is not allowed to connect to this MySQL server
at Handshake.Sequence._packetToError (/home/timetrackingadm/www/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/home/timetrackingadm/www/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/home/timetrackingadm/www/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/timetrackingadm/www/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/timetrackingadm/www/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/timetrackingadm/www/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/home/timetrackingadm/www/node_modules/mysql/lib/Connection.js:88:28)
at Socket. (/home/timetrackingadm/www/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:314:20)
at addChunk (_stream_readable.js:298:12)
at readableAddChunk (_stream_readable.js:273:9)
at Socket.Readable.push (_stream_readable.js:214:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(…)

I’m running a Strapi v3.0.0-beta.19.3, on Node JS 12.19.0 and a MySQL 5.6

Do you know who resolves localhost ? And how to not resolve it ?

Thanks for the read !

Functionally speaking; localhost == 127.0.0.1

As a side point though

You are running a version of Strapi we no longer support.

Thanks Derrick for your reply : well I’d like to say so, that 127.0.0.1 is always localhost, but somehow, and unfortunately for reasons I can’t understand, an adminsys, decided, someday, that my MySQL database should always be accessed by using “localhost” and not 127.0.0.1…

Moreother, localhost needs an additionnal lookup I guess, I can’t really say as it’s out of my daily job :frowning:.

I’ll try to update my Strapi setup and keep this thread updated.

That would be the strangest decision I’ve ever seen but yes please keep us in the loop