Laravel中的MongoDb身份验证仅针对localhost失败

We recently shifted our shifted our database (MongoDb) and a Laravel application to a new server. Earlier everything was working fine when both, the database and 2 Laravel apps were on the same server. I then shifted the MongoDb to a new server. Again things were working fine. Later I shifted one of the Laravel application to the same new server as the database. Now I am facing issues in authentication for the Laravel server.

This is what is working for me currently: bindIp in MongoDb is set to 0.0.0.0 security.authorization is disabled.

This works but obviously, I cannot have this since anyone can access the database without authorization.

If I keep the security.authorization enabled, my I can connect to the database remotely and also from the same machine using the mongo command line, but the Laravel app on the same machine cannot access it. I get the following error:

Failed to connect to: 127.0.0.1:27017: Authentication failed on database 'abcd' with username 'abcd': auth failed

I have tried various settings with security.authorization and bindIp. Nothing seems to work. The user for the database has the same roles as the one on the previous server.