Connecting to a dynamic port between tasks in the same group

I am writing a job that runs paperless-ngx, which also needs redis. I’ve defined them under the same group and given them dynamic ports with to set to the port they expect. I then pass ${NOMAD_ADDR_redis} to paperless through env so that it may connect through the dynamic port. When I run this job the connection does not go through and ends up timing out. If I pass an incorrect address it fails instantly. The only way I’ve gotten the services to connect is by not specifying the port from Nomad and allowing it to default to 6379 (which is what redis listens on and its port to value is set to) on localhost.

Is there something I am missing? I was under the impression that it was mandatory to use the dynamic port, even within the same task group and with networking set to “bridge”. If this is how it is intended to work then that is fine but the more I read documentation the more I worry that this is just some quirk in how I’ve configured my cluster. I am able to connect to the dynamic port from outside the task but never within (I made a custom image with redis-cli included to check this).

Here’s the job I am using:
(note that I have to remove the PAPERLESS_REDIS env variable from this so it’ll use localhost to allow the job to work)

{
  "Datacenters": [
    "dc1"
  ],
  "ID": "paperless",
  "Name": "paperless",
  "TaskGroups": [
    {
      "Count": 1,
      "Name": "paperless",
      "Networks": [
        {
          "DynamicPorts": [
            {
              "Label": "http",
              "To": 8000
            },
            {
              "Label": "redis",
              "To": 6379
            }
          ],
          "Mode": "bridge"
        }
      ],
      "Services": [
        {
          "Checks": [
            {
              "Interval": 20000000000,
              "Name": "paperless alive",
              "Path": "/",
              "Timeout": 5000000000,
              "Type": "http"
            }
          ],
          "Name": "paperless",
          "PortLabel": "http"
        }
      ],
      "Tasks": [
        {
          "Config": {
            "command": "/usr/local/bin/paperless_cmd.sh",
            "entrypoint": [
              "/sbin/docker-entrypoint.sh"
            ],
            "image": "justinrubek/paperless:latest",
            "ports": [
              "http"
            ],
            "work_dir": "/usr/src/paperless/src"
          },
          "Driver": "docker",
          "Env": {
            "PAPERLESS_ADMIN_PASSWORD": "REDACTED",
            "PAPERLESS_ADMIN_USER": "admin",
            "PAPERLESS_OCR_LANGUAGES": "eng",
            "PAPERLESS_REDIS": "redis://${NOMAD_ADDR_redis}",
            "PAPERLESS_SECRET_KEY": "REDACTED",
            "PAPERLESS_TIME_ZONE": "America/Chicago",
            "USERMAP_GID": "1000",
            "USERMAP_UID": "1000"
          },
          "Name": "paperless",
          "Resources": {
            "CPU": 500,
            "MemoryMB": 1000
          },
          "VolumeMounts": [
            {
              "Destination": "/usr/src/paperless/consume",
              "ReadOnly": false,
              "Volume": "paperless_consume"
            },
            {
              "Destination": "/usr/src/paperless/data",
              "ReadOnly": false,
              "Volume": "paperless_data"
            },
            {
              "Destination": "/usr/src/paperless/media",
              "ReadOnly": false,
              "Volume": "paperless_media"
            }
          ]
        },
        {
          "Config": {
            "image": "redis:6",
            "ports": [
              "redis"
            ]
          },
          "Driver": "docker",
          "Lifecycle": {
            "Hook": "prestart",
            "Sidecar": true
          },
          "Name": "redis",
          "Resources": {
            "CPU": 20,
            "MemoryMB": 128
          }
        }
      ],
      "Volumes": {
        "paperless_consume": {
          "AccessMode": "single-node-writer",
          "AttachmentMode": "file-system",
          "Name": "paperless_consume",
          "ReadOnly": false,
          "Source": "paperless_consume",
          "Type": "csi"
        },
        "paperless_data": {
          "AccessMode": "single-node-writer",
          "AttachmentMode": "file-system",
          "Name": "paperless_data",
          "ReadOnly": false,
          "Source": "paperless_data",
          "Type": "csi"
        },
        "paperless_media": {
          "AccessMode": "single-node-writer",
          "AttachmentMode": "file-system",
          "Name": "paperless_media",
          "ReadOnly": false,
          "Source": "paperless_media",
          "Type": "csi"
        }
      }
    }
  ]
}

Full disclaimer: I am running this cluster on NixOS and it is all connected through Tailscale. I wouldn’t be all too surprised if this is another quirk related to using these but I don’t currently know how that would be the case

The “dynamic port” is the host-port that gets exposed & routed into the target container port (“6379”).

Since you’re running in the same Group & use bridge networking, the tasks can communicate locally, and you should/could just use “127.0.0.1:6379”