- Start PowerShell/CMD as admin and run the following command:
mongod --dbpath="C:\Program Files\MongoDB\Server\4.2\data". --bind_ip=0.0.0.0
Your server now must be running
- From the unix terminal (Ubuntu in my case) run the following command:
cat /etc/resolv.conf
The output should be something like this (if you have automatic generation enabled, which it is by default:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 122.1.1.1
And copy the direction from nameserver.
- Set the Mongo URI for your client with the IP that you have copied. E.g for Flask it would be something like this:
app.config['MONGO_URI'] = 'mongodb://122.1.1.1:27017/<your_db_name>'
The default port for a mongodb server on your local is 27017
- Run your app and the connection should work.
It's been a long time coming, but it really worked for me. Thank you!