Can't access mongodb from external network or from public ip

my docker compose is this:

version: ‘3.1’

services:
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: ###
volumes:
- mongodb_data:/data/db
- mongodb_config:/data/configdb
ports:
- 27017:27017 # Expose port 27017
networks:
- mongodb_network

mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: ######
ME_CONFIG_MONGODB_URL: mongodb://root:#####@mongo:27017/
ME_CONFIG_BASICAUTH_USERNAME: ‘admin’
ME_CONFIG_BASICAUTH_PASSWORD: ‘#########’
ME_CONFIG_MONGODB_ENABLE_ADMIN: ‘true’
ME_CONFIG_MONGODB_PORT: 27017
ME_CONFIG_MONGODB_SERVER: ‘mongo’
ME_CONFIG_OPTIONS_EDITORTHEME: ‘3024-night’
networks:
- mongodb_network

volumes:
mongodb_data:
mongodb_config:

networks:
mongodb_network:

I can connect from 192.168.2.105:27017 but it’s not letting me to connect 117.242.151.204, I have forwarded the port, so it’s not any port issue, I tried with other open port which is working already with my ISP, still from that port also can’t access mongodb, is there anything like allowed IP?

Please update your post:

1 Like