Bug 254948 - databases/mariadb105-server fails to resolve localhost
Summary: databases/mariadb105-server fails to resolve localhost
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Bernard Spil
Depends on:
Reported: 2021-04-10 16:18 UTC by John R
Modified: 2021-05-22 23:50 UTC (History)
4 users (show)

See Also:
linimon: maintainer-feedback? (brnrd)


Note You need to log in before you can comment on or make changes to this bug.
Description John R 2021-04-10 16:18:03 UTC
mariadb104 or mariadb105 fail to resolve localhost and therefore cannot connect to local db instance, suspect skip_name_resolve is locked to 1 as numeric ip works. Querying localhost with resolveip returns expected result.
Comment 1 Marek Zarychta 2021-04-10 16:41:09 UTC
Is MariaDB client supposed to connect to localhost instead of file socket? Is MariaDB server listening on localhost is the socket not firewalled? What is localhost address/addresses in your case ?
Comment 2 John R 2021-04-10 17:01:22 UTC
I see the issue on *-server, regardless of whether the localhost is or or 1127.0.2.1 etc.
Comment 3 Marek Zarychta 2021-04-10 17:45:01 UTC
(In reply to John R from comment #2)
localhost usually resolves to ::1. Are you sure that IPv6 is supported in your install ?
Comment 4 John R 2021-04-10 17:53:21 UTC
I don't use ipv6 and I never mentioned it.
Comment 5 Marek Zarychta 2021-04-10 18:00:35 UTC
Could you please describe it better? How can one reproduce your issue?
Comment 6 John R 2021-04-10 18:04:44 UTC
If I have a website running that requires backend connection to the db, it fails to connect when the ipaddress is set up as localhost, however when I change it to the numeric ip, it connects. That better? :)
Comment 7 Marek Zarychta 2021-04-10 18:46:00 UTC
I believe it's not a bug. Please consider closing this PR and checking/editing  the contents of /etc/hosts or/and enabling connections and required grants on [::1]:3306 socket.
Comment 8 John R 2021-04-10 20:23:59 UTC
What exactly should I have in /etc/hosts ?

At the moment it is like this...

#::1			localhost localhost.my.domain		hostname.domain.co.uk BuildBSD localhost localhost.domain.co.uk

Host and domain obfuscated.
Comment 9 John R 2021-04-10 20:29:09 UTC
Also I had grants for user@localhost and user@ added too. Made no difference till I changed localhosts to on the website connection details.
Comment 10 John R 2021-04-10 20:31:55 UTC
Additionally, mariadb provides resolveip which I used to confirm it did see localhost as the expected, still failed to connect.
Comment 11 Vincent Milum Jr 2021-05-22 23:50:57 UTC
This is expected behavior of MySQL and MariaDB. When the hostname is equal to "localhost", the protocol uses UNIX Sockets rather than TCP Sockets. While the linked document is for MySQL 8.0, this has been the norm throughout the MySQL/MariaDB 5.x days and still in MariaDB 10.x. This is basically a legacy "feature" in MySQL that has never been changed.