Container communication isn't working

Hey,

I have a simple docker file running a node service that should connect to a mongodb.
Unfortunately, my services don’t seem to know about each other within the network of I defined.

Here’s an example of my docker-compose file

version: '3'

services:
  api:
    image: myproject/api
    ports:
      - 8082:8082
    command: npm start
    networks:
      - mynetwork
    depends_on:
      - api-mongo  
  api-mongo:
    image: mongo
    ports:
      - 27082:27017
    networks:
      - mynetwork

networks:
  mynetwork:

When I inspect the services, they have the network alias based on the service name…
However, my node api doesn’t seem to be able to resolve the host api-mongo

I’ve been on a million threads online trying to figure this out and can’t seem to get it to work under no conditions.

Ideally,
I aim to have multiple node instances talking to a mongo instance each, and so I want each to have a different port (That’s why 27082 for example).

Any help would be much appreciated.