Temporary failure in name resolution – Error when containerA uses containerB.internal as database host

Hello, I have no idea what I’m doing wrong! :smiling_face_with_tear:

I’m running Wordpress in one container, and Maria DB in another.

Wordpress is incredibly slow and also often just redirects to a Error establishing a database connection screen with the following debug message:

Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/wp-includes/wp-db.php on line 1753 Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/wp-includes/wp-db.php on line 1753

php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

I was hoping for an easy setup and not really sure what I’m doing but these are my two toml files:

Wordpress:

# fly.toml file generated for ias on 2022-09-13T17:29:38+02:00

app = "ias"
kill_signal = "SIGINT"
kill_timeout = 5

[mounts]
  source = "ias_wp_content"
  destination = "/var/www/html"

[env]
  WORDPRESS_DB_HOST = "wp-maria.internal"
  WORDPRESS_DB_NAME = "wordpress"
  WORDPRESS_DB_USER = REDACTED
  WORDPRESS_TABLE_PREFIX = "ias_"
  WORDPRESS_DEBUG = 1

[build]
  image = "designbyadrian/wordpress:php7.4-apache-amd"

[[services]]
  internal_port = 80
  protocol = "tcp"
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

DB:

# fly.toml file generated for wp-maria on 2022-09-13T16:41:11+02:00

app = "wp-maria"
kill_signal = "SIGINT"
kill_timeout = 5

[mounts]
  source = "mariadata"
  destination = "/data"

[env]
  MARIADB_DATABASE = "wordpress"
  MARIADB_USER = REDACTED

[build]
  image = "mariadb:10"

[experimental]
  cmd = [
    "--datadir","/data/maria"
  ]

In this post, I’ve with help figured out that the two containers can talk to each other, but something is just off.

Thanks for linking to the previous topic! I’m glad to see that you’ve confirmed that your db is listening on IPv6 for the correct port.This is by far the most common cause of .internal DNS woes :sweat_smile:

Since you can connect to the database via mysql, it would initially seem like the Fly platform settings and behavior is working correctly.

Checking the wp-db docs for mysqli specifically, I think it’s possible that you might be running into a Wordpress issue? I found this thread, which might be a good jumping-off point:

Currently, I’ve got this line:

WORDPRESS_DB_HOST = "wp-maria.internal"

Are you saying that I should write something like

WORDPRESS_DB_HOST = "fe80::ec4:XXXX:XXXX:XXXX" instead?

There were no IP addresses on the DB container, so I assigned one with flyctl ips allocate-v6 and modified the DB_HOST variable. The site didn’t load properly at all and went straight to the database error page after a few seconds of delay :frowning:

But sporting the new IPV6 IP, I reverted the change to the WP container, and I seem to be able to use it just fine! :slight_smile: I’ll keep a look out for more issues for now.

Why would this make a difference? Should I assign a V4 IP as well?

Update: it’s fast for every few clicks, then a slow load but displays the page.

I could use it for a while, but now back to the same issue :frowning:

I’ve been trying to figure out what the post you linked would solve in the first place… :thinking: