0

I want to connect to a Google cloud SQL instance using its free IPv6 address instead of buying an IPv4 address. For that I looked up my IPv6 address and allowed it. I also looked up my routers IPv6 prefix and allowed that (afaik that should allow all pc in my home network to access the SQL instance).

The following code creates the problem:

$servername = "2001:6532:1234:1:6a4f:e1d7:5d69:52a3";
$username = "looooool";
$password = "superSecretStuff";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

And that code generates this error:

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt. in C:\Users\kjh\Documents\SF WEBSITE\appengine-try-php-master\connect_db.php on line 8

Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt. in C:\Users\kjh\Documents\SF WEBSITE\appengine-try-php-master\connect_db.php on line 8
Connection failed: php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt.

I'm sorry that the error message is in German, but I don't know where I would even change that. Also line 8 is the line with $conn = new mysqli($servername, $username, $password, $dbname); on it. I've changed the IP adress so if it looks weird that is why. Hope you can help me.

If I get an IPv4 adress from Google it works without any problems.

This is a repost from here where I was told to reask it here, because it could be a problem with my ISP not assigning a persistent IPv6 address.

After I just wanted to look up my IPv6 address I noticed somethin strange. I went to wieistmeineip.de to look up my IPv6 address and at first it only showed my IPv6 address, then when I went to the speedtest my IPv6 address vanished, and I only have an IPv4 address since then. At least that is what all the ip address sites say. Also the same happend with google when you google "what is my ip address" google shows you your ip address, at first it showed my ipv6 and now it only shows ipv4.

My ISP: Kabel Deutschland

Now finnally my two questions:

  1. Should the code above work given that I permitted my IPv6 address to access the cloud sql and that my ISP is not screwing me up?

  2. Is there some way I could check if my ISP is doing something strange?

Update:

I tried to disable IPv4 completely on my machine (Windows) so I did that and restarted my computer. After the restart I did not get an IPv6 address from my router so I enabled IPv4 again, and I got an IPv4 address but no IPv6 address. I hope that helps.

14
  • Please try myip.addr.space as I built this to detect users' IPv4 and IPv6 addresses properly in most circumstances. The result it gives may shed some light on your situation. Nov 28, 2015 at 19:13
  • This error »Der angegebene Host ist unbekannt« means Unknown host. So it suggests that PHP has not recognized your host as a valid IP address and is attempting to treat it as a hostname. Are you sure you have entered the IPv6 address correctly in your PHP code? The one shown in your question doesn't appear to be valid. Nov 28, 2015 at 19:19
  • Well, now I have an IPv6 address again... It is diffrent from the address I had befor so I added it to the allowed IPs with Cloud SQL, but I get the same error again.
    – usbpc102
    Nov 28, 2015 at 19:20
  • Yes I have used the correct IPv6 address in my code, I just changed it here to not make it public. But that it does not see that as a valid host is confusing me aswell because I'm wondering if the syntax for IPv6 is diffrent.
    – usbpc102
    Nov 28, 2015 at 19:23
  • If there's a question about PHP syntax you probably should go back to Stack Overflow, because we don't really know about that here :) I even took a look at the PHP documentation for mysqli but it doesn't address the question of IPv6 at all. Nov 28, 2015 at 19:24

1 Answer 1

1

So I can answer the question myself now, with help from Michael Hampton.

  1. No. The IPv6 address needs to be in square brackets. So the following should work: $servername = "[2001:6532:1234:1:6a4f:e1d7:5d69:52a3]";

  2. The way to check is to just try over and over again after you have got the right code. In my case my home network was doing something strange, and restarting all my network gear fixed it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .