But would any network issue cause the inability to access the database on localhost?
"localhost" configuration is special. As a mariadb/mysqld feature it is using the unix socket. But Kodi's mariadb-connector-c defaults to /tmp/mysql.sock whereas the mariadb addon is configured to /run/mariadb/mysql.sock.
TL;DR: Unless it is fixed use 127.0.0.1 instead.