Search code examples
node.jsdockerdocker-composefeathersjs

Node docker not working for feathersjs - Container running but localhost not accessable


I have a docker-compose file with mongo and an node container, mongo works great, but the node feathers container is not accessable from localhost:3030 (have also tried 127.0.0.1:3030 and 0.0.0.0:3030

version: "3"
services:
  app:
    image: node:lts-alpine
    volumes:
      - ./feathers-full:/app
    working_dir: /app
    depends_on:
      - mongo
    environment:
      NODE_ENV: development
    command: npm run dev
    ports:
      - 3030:3030
    expose:
      - "3030"
  mongo:
    image: mongo
    ports:
      - 27017:27017
    expose:
      - "27017"
    volumes:
      - ./data/db:/data/db

Solution

  • Are you binding to 127.0.0.1 in the Feathers server? If so, you won't be able to access the server from outside the container. You need to bind to 0.0.0.0. See https://pythonspeed.com/articles/docker-connection-refused/ for explanation why.