0

I went through all the possible articles about this problem on StackOverflow and Github and none of the solutions works, that's why I decided to post another question.

I've setup mongo with mongo-express on docker-compose and when I run it everything seems good except that when I try it through web browser it says ERR_EMPTY_RESPONSE

Docker-compose:

version: '3.1'
services:
  mongo:
    image: mongo
    restart: always
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  mongo-express:
    image: mongo-express
    restart: always
    depends_on:
      - "mongo"
    ports:
      - "8081:8081"
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example
      ME_CONFIG_MONGODB_SERVER: mongo

Logs from docker mongo-express:

Welcome to mongo-express
------------------------


(node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!

Docker ps:

CONTAINER ID   IMAGE           COMMAND                  CREATED              STATUS              PORTS                      NAMES
a97ae1a348c6   mongo-express   "tini -- /docker-ent…"   About a minute ago   Up About a minute   0.0.0.0:8081->8081/tcp     docker-compose-mongo-express-1
d645863a90de   mongo           "docker-entrypoint.s…"   2 hours ago          Up About a minute   0.0.0.0:27017->27017/tcp   docker-compose-mongo-1

I tried also as it was suggested on other posts to run mongo-express on 0.54.0 image version. Below is the result:

Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
Database connected
Admin Database connected
unable to list databases
Error [MongoError]: Unsupported OP_QUERY command: listDatabases. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal
    at Function.MongoError.create (/node_modules/mongodb-core/lib/error.js:31:11)
    at /node_modules/mongodb-core/lib/connection/pool.js:483:72
    at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:429:16)
    at Connection.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:463:5)
    at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:319:22)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  ok: 0,
  errmsg: 'Unsupported OP_QUERY command: listDatabases. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal',
  code: 352,
  codeName: 'UnsupportedOpQueryCommand'
}

All looks good, except of I can't access mongo-express from outside docker container. Do you have any other ideas what might be wrong?

Rafał Sokalski
  • 1,817
  • 2
  • 17
  • 29
  • If you're trying to do that on windows, make sure you're running your docker-compose command using **Powershell** itself, even running the command from the windows terminal's powershell would cause the same problem. aslo change your `ME_CONFIG_MONGODB_SERVER` to `mongodb` – Rocky Feb 22 '23 at 15:05

1 Answers1

0

I suggest you try the following:

Skully
  • 2,882
  • 3
  • 20
  • 31
azerELweed
  • 67
  • 1
  • 11