How to reach localhost on host from docker container?

Good morning,

sorry for confusing you.

I meant it this way:
remove the lines

extra_hosts:
      - "host.docker.internal:host-gateway"

from your docker-compose.yml

replace the lines

external_links:
  - mongo

by

links:
  - mongo

within your docker-compose.yml’s app-section because you want to connect to a container defined within the same docker-compose.yml

To connect to the mongo-container from app-container use the hostname mongo

To connect to your host’s localhost from within a container use 172.17.0.1 (as you are running on Linux). It would be host.docker.internal if you running Docker on Windows.