Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

509
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!