mongoose failing to connect in docker-compose

I’ve got a simple docker-compose.yml that looks like this:

services:
  mongodb-service:
    image: mongo:latest
    command: "mongod --bind_ip_all"
  mongodb-seeder:
    image: mongo:latest
      depends_on:
        - mongodb-service
      command: "mongoimport --uri mongodb://mongodb-service:27017/auth --drop --file /tmp/users.json"
  myapp:
    image: myapp:latest
    environment:
      DATABASEURL: mongodb://mongodb-service:27017/auth
    depends_on:
      - mongodb-service

myapp is a nodejs app that uses mongoose to connect to a mongodb database like so:

const databaseURL = process.env.DATABASEURL;
async function connectToMongo() {
    try {
        return await mongoose.connect(databaseURL, {
            useUnifiedTopology: true,
            useNewUrlParser: true,
            useCreateIndex: true,
        });
    }
    catch (error) {
        logger.error('MongoDB connect failure.', error);
    }
}

mongodb-seeder works perfectly fine. I can kick it off, it connects to mongodb-service and runs the import without any problems. However, myapp starts up, tries to connect to mongodb-service for 30 seconds, then dies:

ERROR 2020-09-16T12:13:21.427 [MAIN] MongoDB connection error! [Arguments] {
  '0': MongooseError [MongooseTimeoutError]: Server selection timed out after 30000 ms
      ...stacktrace snipped...
      at Function.Module._load (internal/modules/cjs/loader.js:724:14) {
    message: 'Server selection timed out after 30000 ms',
    name: 'MongooseTimeoutError',
    reason: Error: connect ECONNREFUSED 127.0.0.1:27017
        at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
      name: 'MongoNetworkError',
      [Symbol(mongoErrorContextSymbol)]: {}
    },
    [Symbol(mongoErrorContextSymbol)]: {}
  }
}

Note: The IP address in this log says it tried to connect to 127.0.0.1, not mongodb://mongodb-service:27017/auth. No matter what value I put in for DATABASEURL, it keeps printing 127.0.0.1. Any ideas why I can’t get mongoose to recognize the hostname I’m giving it? And why would mongoose not be able to connect to a service that’s clearly network-visible, since another container (mongodb-seeder) can see it without any problems?

Edit: I’m using mongoose 5.8.7

Source: Docker Questions