FYI -- localhost and 127.0.0.1 not always interchangable with python and mysql/mariadb

I recently worked with a client on his project that was my first time working with python thru apache and MariaDB, and learned something new !!

it seems with python, and possibly other code/languages too, that the code makes assumptions based upon the word LOCALHOST – if localhost is used as the host/target/server in the python configuration, then a unix socket is looked for to make a database connection to MariaDB; if 127.0.0.1 is listed for host, then a tcp socket connection to 3306 (by default) is attempted.

Speaking in general, I’m sure in a pure tcp socket setting, with something like localhost:8002 and 127.0.0.1:8002 (a typical php-fpm setting) it would not matter.

Just wanted to share as this was all news to me :smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.