The fact that you mentioned 2 OS

and

makes me think that you do not understand localhost correctly.

If mongod is running on Windows 10 and you try to connect from your node application running on Ubuntu, localhost is definitively note the way you should connect. Your localhost in Windows that let you connect to your Windows’ mongod is not the same localhost as your Ubuntu machine running your host.

The host localhost is really your local host. It means localhost on Windows is Windows and localhost on Ubuntu is Ubuntu. If you want to connect to mongod running on Windows from your app running on Ubuntu you will need to specify something else than localhost. The host name of your Windows machine is a likely candidate.