Wordpress can't connect to MariaDB (Nomad, Consul, Consul Connect)

I’m currently having trouble having the wordpress container connect to mariadb (deployed using nomad with consul and consul connect)

wordpress.nomad:

job "wordpress-test" {
  datacenters = ["ov-dc1"]
  type = "service"
  
  constraint {
    attribute = "${node.unique.name}"
    value = "client_2"
  }

  group "wordpress" {
    network {
      mode = "bridge"
      port "http" {
        static = 8085
        to = 80
      }
    }
    service {
      name = "wordpress"
      port = "8085"
      connect {
        sidecar_service {
          proxy {
            upstreams {
              destination_name = "mariadb"
              local_bind_port = 3306
            }
          }
        }
      }
      
        tags = ["global", "wordpress"]
        tags = [
          "traefik.enable=true",
          "traefik.http.routers.wordpress.entrypoints=http",
          "traefik.http.routers.wordpress.rule=host(`masked.com`, `masked2.com`)",
	   "traefik.http.routers.wordpress.middlewares=wordpress-redirect",
          "traefik.http.middlewares.wordpress-redirect.redirectscheme.scheme=https",
          "traefik.http.middlewares.wordpress-redirect.redirectscheme.permanent=true",
          "traefik.http.routers.wordpress-ssl.entryPoints=https",
          "traefik.http.routers.wordpress-ssl.rule=host(`masked.com`, `masked2.com`)",
	   "traefik.http.routers.wordpress-ssl.tls=true",
          "traefik.http.routers.wordpress-ssl.tls.certResolver=ssl-gate",
          "traefik.http.routers.wordpress-ssl.service=wordpress-ssl",
          "traefik.http.services.wordpress-ssl.loadBalancer.server.port=8085"
        ] 
      }
    task "wordpress" {
      driver = "docker"
      config {
        image = "wordpress:latest"
    }
      env {
        WORDPRESS_DB_PASSWORD = "wordpress"
        WORDPRESS_DB_HOST = "${NOMAD_UPSTREAM_ADDR_mariadb}"
        WORDPRESS_DB_USER = "wordpress"
        WORDPRESS_DB_NAME = "wordpress"

      }
      resources {
        memory = 100
      }
      }
  
  }
  group "db" {
    network {
      mode = "bridge"
      port "db" {
        to = 3306
      }
    }
    service {
      name = "mariadb"
      port = "db"
      connect {
        sidecar_service {}
      }
      tags = ["global", "wordpress-mariadb"]        
    }
    task "mariadb1" {
        driver = "docker"
        config {
            image = "mariadb:latest"
            volumes = [
          ".database:/var/lib/mysql"
          ]
        }
        env {
            MYSQL_ROOT_PASSWORD = "wordpress"
            MYSQL_USER = "wordpress"
            MYSQL_PASSWORD = "wordpress"
            MYSQL_DATABASE = "wordpress" 
        }
        resources {
            memory = 100
        }
        
       }
  }
}

wordpress error logs:


MySQL Connection Error: (2006) MySQL server has gone away
[06-Oct-2020 07:24:23 UTC] PHP Warning:  mysqli::__construct(): Error while reading greeting packet. PID=185 in Standard input code on line 22
[06-Oct-2020 07:24:23 UTC] PHP Warning:  mysqli::__construct(): (HY000/2006): MySQL server has gone away in Standard input code on line 22

MySQL Connection Error: (2006) MySQL server has gone away

WARNING: unable to establish a database connection to '127.0.0.1:3306'
  continuing anyways (which might have unexpected results)

AH00557: apache2: apr_sockaddr_info_get() failed for cc7ffe840b4f
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
AH00557: apache2: apr_sockaddr_info_get() failed for cc7ffe840b4f
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[Tue Oct 06 07:24:43.401161 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.11 configured -- resuming normal operations
[Tue Oct 06 07:24:43.401364 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

Thanks for the response

Were you able to resolve this issue?