2005 (HY000): Unknown server host '127.0.0.1

Discussion in 'General' started by kataiwo, Nov 4, 2024.

  1. kataiwo

    kataiwo New Member

    Hello,
    I have a fresh Debian 12 Server and I just configure now using automated ISPConfig script, everything works fine except that I now notice that I get ERROR: 2005 (HY000): Unknown server host '127.0.0.1 when I tried dto connect on the terminal using mysql -u root -p, however I am able to connect using mysql -h localhost -u root -p.

    Any clue as to why 127.0.0.1 is not recognised? I have other older servers (all Debian 12 but not the latest ISPConfig) and they don't have this issue.

    Thanks for your helps.
     
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    have you edited, or deleted, the line 127.0.0.1 localhost in your /etc/hosts file?
     
  3. kataiwo

    kataiwo New Member

    No it is still there, this is what puzzles me.

    Also when i do netstat -tap, I don't see 127.0.0.1..., I only see 0.0.0.0... or localhost.localdomain... or the public servername.... for all processes.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    o.o.o.o is fine, it means all IP addresses incl. 127.0.0.1.

    I wonder why it says '127.0.0.1 with just one quote at the beginning. maybe you quoted the value wrong and missed the closing quote? Try to remove all quotes, 127.0.0.1 does not need to be quoted.
     
  5. kataiwo

    kataiwo New Member

    I don't understand the single quote too, there is no quote in /etc/hosts/ and there is no white space too. I notice this affects mysql and mongodb because i have 127.0.0.1 in the connection string.
     
  6. kataiwo

    kataiwo New Member

    Oh, I just rechecked now, the single quote is closing an opening one, it is from mysql, the full response is below:
    ' (-2)2005 (HY000): Unknown server host '127.0.0.1
     
  7. remkoh

    remkoh Active Member HowtoForge Supporter

    It's almost like the IP is treated as a fqdn.
    Or you managed to loose your "lo" (loopback) networkinterface.
    What is the output of
    Code:
    ip addr
     
  8. kataiwo

    kataiwo New Member

    Here it is:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:55:ef:24 brd ff:ff:ff:ff:ff:ff
    altname enp0s18
    altname ens18
    inet x.x.x.x/24 brd x.x.x.255 scope global eth0
    valid_lft forever preferred_lft forever
     
  9. remkoh

    remkoh Active Member HowtoForge Supporter

    So the "lo" interface is in place.

    You're sure there is not a typo somewhere by accident? In /etc/hosts for example?

    And what do you get when you simply ping to 127.0.0.1 from the console or a ssh session?
     
  10. kataiwo

    kataiwo New Member

    No typo and I have checked and checked and also reinstalled the server.

    I get a response back when i ping 127.0.0.1
     
  11. remkoh

    remkoh Active Member HowtoForge Supporter

    And connecting using telnet client?
    Code:
    telnet 127.0.0.1 3306
     
  12. kataiwo

    kataiwo New Member

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    c
    5.5.5-10.11.6-MariaDB-0+deb12u1=(QB3x'RK��-^yfq&eN7g~hnmysql_native_passwordConnection closed by foreign host.
     
  13. kataiwo

    kataiwo New Member

    Also when i tried connecting my app, i get Error: getaddrinfo ENOTFOUND 127.0.0.1
     
  14. remkoh

    remkoh Active Member HowtoForge Supporter

    Ok, just a plain connection is possible.
    So there's nothing wrong with your loopback interface and MariaDB is listening on it's IP.

    No clue on why you encounter the problems you are having using 127.0.0.1 and not localhost.
    Difference between the two is that localhost connects to MariaDB's unix socket and 127.0.0.1 is a tcp connection.
     
  15. kataiwo

    kataiwo New Member


    Thanks for all your help on this.
    It turned out that I have a environment variable that is also a reserved phrase and this confused the server. All is well now.
    Many thanks.
     
    remkoh likes this.

Share This Page