Docker network connecting to mongo - stumped

Hello, I am trying to connect to my mongo container with the name of the container and it’s not working

Connecting to mongo by container name doesn’t work
Connecting to: mongodb://@lspdaacs-mongo:27009/foo23?authSource=admin&directConnection=true&appName=mongosh+2.2.3
MongoNetworkError: connect ECONNREFUSED 172.29.0.4:27009

Connecting by public IP works
root@88b101947771:/usr/src/app# mongosh mongodb://meow:userpasswd@192.168.10.4:27009/foo23
Current Mongosh Log ID: 661c5517b51f4ed548ef634a
Connecting to: mongodb://@192.168.10.4:27009/foo23?directConnection=true&appName=mongosh+2.2.3

I can ping the container and that returns packets
PING lspdaacs-mongo (172.29.0.4) 56(84) bytes of data.
64 bytes from lspdaacs-mongo.myNetwork (172.29.0.4): icmp_seq=1 ttl=64 time=0.077 ms

What am I doing wrong? I am stumped… I’ve googled it a millon times and every body says to make sure that it’s on the same network and it is.

Ubuntu 22.04 Jammy

Docker Compose version v2.18.1

Server: Docker Engine - Community
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:51:00 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0

Good morning,
from one container to the other using the container’s name should work.
From your docker-host to the container you can use localhost IF you expose the container’s port to your docker host.

I figured it out. So if your using the container name then you have to use the real port, and not the mapped port

For example if your using public IP then
mongodb://username:password@123.456.789.102:27009/databasename

IF your using container name
mongodb://username:password@mongo:27017/databasename