Gitlab CI/CD pipeline tests fails to connect to MongoDB Atlas even though my local machine testing does

When running NestJS tests in my local machine all tests runs smoothly and no error arises. However, when my pipeline runs tests on Gitlab, it fails to connect to the MongoDB Atlas giving the following error. ERROR [MongooseModule] Unable to connect to the database. Same happens when simply trying to run the server on the pipeline.

From working around with the app, I have noticed that environment variables are indeed recognized by the gitlab pipeline environment and that my MongoDB atlas is also allowing all IP addresses to access it, so I have no idea what to do, any help would be greatly appreciated.

I think GitLab is using some sort of firewall which is preventing communication with any third party API’s (in this case MongoDB Atlas) as the connection works when the app is deployed on Heroku.