Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

516
Vistas
Dockerized MongoDB Failing to connect on Heroku from NodeJs Container

i have a node web service and I'm a bit new to docker, so please bear with me. Below is my docker-compose file. I have run this image locally and it works fine, but when trying to deploy it to Heroku I get the following error:

{ MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017]

I've found where I'm supposed to set the environment flags in Heroku, so I managed to check that and its fine. But it still can't find mongo:27017

What could I be doing wrong?

version: "3"
services:
  mongo:
    container_name: mongo
    image: mongo
    volumes:
      - ./data:/data/charecters
    ports:
      - "27017:27017"
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=password
  mongo-seed:
    build: ./mongo-seed
    links:
      - mongo
    volumes:
      - ./mongo-seed:/mongo-seed
    command:
      - /mongo-seed/script.sh
  app:
    container_name: app
    restart: always
    build: .
    ports:
      - "3000:3000"
    links:
      - mongo
    environment:
      - DB_SERVERS=mongo:27017
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

links:
      - mongo

is depreciated try 

depends_on:
     - mongo

also, check that 

mongo:
    container_name: mongo, is properly referenced in DB setup

change command:
  - /mongo-seed/script.sh

try command:
   - 'node your-app-file'
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda