Keep getting this error when connecting: Server record does not share hostname with parent URI

even when I directly put the mongo db url, it still doesn’t work:

mongoose
  .connect('mongodb+srv://username:jSnSniWBTlbu4SjX@hostname.fepglzk.mongodb.net/?retryWrites=true&w=majority')
  .then(() => {
    app.listen(port)
    console.log('MongoDB connected successfully.');
  })
  .catch((err) => {
    console.error('Failed to connect to MongoDB:', err);
  });

I get the same error