Connect ETIMEDOUT when attempting to connect to database hosted on oracle vm

I have been trying to host a mongo db server on a oracle virtual machine (using oracle linux 8). I have been using the mongodb extention for vscode to test the connection, but I keep getting this error:
“Unable to load connection: MongoServerSelectionError: connect ETIMEDOUT :27017”
Here are my connection settings:


I also remembered to port forward the port 27017.
The service is enabled. I can connect to it via the command line when I have connected to the vm via ssh:

[root@instance-20230214-2159 opc]# mongo --port 27017 --authenticationDatabase "admin" -u "<redacted>" -p
MongoDB shell version v4.4.18
Enter password:
connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb

Im not sure what Im doing wrong. Does anyone have any idea?
Thanks in advance!

It could be that the server is only bound to 127.0.0.1 and not listening on a lan IP.

Check your configuration file for bindIp or bindIpAll :

grep bindIp /etc/mongod.conf

If you need to connect to the database from other hosts then this will need to be updated, the default is to only bind localhost. If you only need vscode to access it remotely consider using the “SSH Tunnel” options on the connection form.

Also be aware of how to secure your installation once you allow access from other source:

Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.