LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-28-2019, 02:35 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Rep: Reputation: 34
PHP MYSQL : MySQLi conn err: Can't get hostname for your address


Hello

I have several Google Cloud servers to which I make a MySQL-connection.

Now there is just 1 MySQL-connection for which I get the error : "MySQLi conn err: Can't get hostname for your address"

This is my code :
Code:
$conn=mysqli_connect('11.22.33.44', "$DBuser", "$DBpwd","MyDatabase");
if (mysqli_connect_errno()) {
    echo "MySQLi conn err: " . mysqli_connect_error();
}
My other connections to other GCP servers is just the same, only IP-address is different.

Anyone knows what could be the reason I am getting this error on this specific MySQL-connection ?
 
Old 08-28-2019, 04:25 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,844

Rep: Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320
https://serverfault.com/questions/17...t-get-hostname
 
Old 08-28-2019, 09:02 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by NevemTeve View Post
Thank you for the link.

The issue goes away after 1 hour or sometimes after 2 hours.

If it is problem of reverse DNS, then why do MySQL-connections to other GCP-servers not give the same issue ?

When I issue
Code:
host 11.22.33.44
44.33.22.11.in-addr.arpa domain name pointer 44.33.22.11.bc.googleusercontent.com.
you see there is no reverse dns set.

But this is exactly the same for all GCP-servers. Only this MySQL-connection reports the error.

FYI "flush hosts" brings back the problem (as suggested in the thread). It does not solve it.
 
Old 08-28-2019, 12:46 PM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,635

Rep: Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205
Quote:
Originally Posted by jonaskellens View Post
Thank you for the link.

The issue goes away after 1 hour or sometimes after 2 hours.

If it is problem of reverse DNS, then why do MySQL-connections to other GCP-servers not give the same issue ?

When I issue
Code:
host 11.22.33.44
44.33.22.11.in-addr.arpa domain name pointer 44.33.22.11.bc.googleusercontent.com.
you see there is no reverse dns set.

But this is exactly the same for all GCP-servers. Only this MySQL-connection reports the error.

FYI "flush hosts" brings back the problem (as suggested in the thread). It does not solve it.
Um...there is a rDNS for that IP. Highlighted.

If the return from host is the same for all servers, then that's not the cause of the problem.
Compare the my.cnf of the "broken" server to ones that work?
 
Old 09-11-2019, 02:12 AM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by scasey View Post
Compare the my.cnf of the "broken" server to ones that work?
The content is exactly the same, namely :
Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
So I still don't understand the difference...
 
Old 09-11-2019, 02:20 AM   #6
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,635

Rep: Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205
Perhaps it's a name resolution problem.
Compare the /etc/resolv.conf on the servers. Is there a difference on the one that doesn't work?
 
Old 09-11-2019, 02:26 AM   #7
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by scasey View Post
Compare the /etc/resolv.conf on the servers.
Content is the same :
Code:
; generated by /sbin/dhclient-script
search c.mygcpservers.internal. google.internal.
nameserver 169.254.169.254
 
Old 09-11-2019, 05:12 AM   #8
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
Can it be in the MySQL version ?
"broken" :
Code:
mysql  Ver 14.14 Distrib 5.5.59, for Linux (x86_64) using readline 5.1
"working" :
Code:
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
 
Old 09-11-2019, 05:59 AM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,844

Rep: Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320
@OP: Did you put the hostname in question into file /etc/hosts ?
 
Old 09-11-2019, 06:57 AM   #10
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by NevemTeve View Post
@OP: Did you put the hostname in question into file /etc/hosts ?
You mean on the host from where I make the MySQL-connection ?
No, there is no content in /etc/hosts for the MySQL-servers.
 
Old 09-11-2019, 08:15 AM   #11
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,635

Rep: Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205
Quote:
Originally Posted by jonaskellens View Post
Can it be in the MySQL version ?
"broken" :
Code:
mysql  Ver 14.14 Distrib 5.5.59, for Linux (x86_64) using readline 5.1
"working" :
Code:
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
Are they both the same OS/version of Linux? What distro and version are they?
Why are the MySQL installs different?
 
Old 09-11-2019, 08:55 AM   #12
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
OS is the same :
Code:
# cat /etc/centos-release 
CentOS release 6.10 (Final)
MySQL versions are different because on 1 server (the problematic one) I upgraded from MySQL 5.1 to 5.5 :
Code:
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
/sbin/service mysqld stop
yum erase mysql mysql-libs
yum install mysql55w mysql55w-server phpmyadmin
/sbin/service mysqld start
 
Old 09-11-2019, 08:59 AM   #13
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 674

Original Poster
Rep: Reputation: 34
I would like to add that this 'problem' (MySQLi conn err: Can't get hostname for your address) starts when the MySQL-server is rebooted. And teh it lasts for 1 hour, sometimes 2 hours, sometimes 6 hours. Untill suddenly the error stops, and the MySQL-connection succeeds.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I install the missing the mysqli extension for PHP to Mysql? bscho Linux Mint 3 07-07-2016 01:33 PM
KDE konsole err msg:QDBusConnection: session D-Bus conn created b4 QCoreAppliction... jimstaffer Red Hat 0 03-03-2012 09:39 PM
which is better "mysql" or "mysqli" to use in php 5.2.6 !? robertjinx Linux - Server 1 12-07-2008 08:32 AM
Php and MySQL Whats this New stuff (Mysqli)? helptonewbie Linux - Newbie 5 04-04-2008 10:59 AM
apache 2.0 + PHP 5 + mysql AND mysqli? nyttoc Linux - Server 1 05-08-2007 08:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration