ajith kumar
ajith kumar

Reputation: 91

MongoDB not running on the provided host and port

I tried to connect to my local mongodb server through compass but It throws me an error "MongoDB not running on the provided host and port", I tried to change the config file many times. I tried setting "bindIpAll: true" , bindIp: my hostname(IPv4 Address), comment the line. Everything is a failure. Anybody help me with this.

Thanks in Advance.

Upvotes: 2

Views: 3694

Answers (4)

Sungharsh J
Sungharsh J

Reputation: 61

I have stumbled with the same issue while using latest mongodb v:6.14.4, my solution is to open cmd and run 'mongo' this gives the path where the mongodb is running if already installed, copy the path from cmd and you can use as below in your node module: const mongodb = "mongodb://127.0.0.1:27017/database-name";

Upvotes: 0

Vinay
Vinay

Reputation: 2339

Just go to task manager then click on services and search for MongoDB, right click on it and start the service. This works for me.

Upvotes: 1

ManuelJE
ManuelJE

Reputation: 519

I had this issue when attempting to connect with mongoDB Compass to a mongoDB on an AWS Ubuntu Linux instance (Lightsail Service to be exact). After reading lots of similar questions here and elsewhere (and having checked my firewall rules to allow port 27017 connections) I went to check the /etc/mongodb.conf file.

By default the bind_ip (at row 11 in my system) comes configured as 127.0.0.1, and that is fine to connect from the same machine. In this config entry you should put all the IP's that are listening for connections.

I tried to add my instance public IP just after a comma

bind_ip = 127.0.0.1,35.xx.xx.xx   (where 35.xx.xx.xx was my public IP)

At this point the service didn't start anymore. I started the service manually while following the log (look under /var/log/mongodb) to read this error message:

2019-03-19T15:51:59.338+0000 [initandlisten] ERROR: listen(): bind() failed errno:99 Cannot assign requested address for socket: 35.xx.xx.xx:27017

So I tried with 0.0.0.0 as suggested on another site but it gave a similar error.

I solved this by putting my AWS instance private IP address in the config file:

bind_ip = 127.0.0.1,172.xx.xx.xx   (where 172.xx.xx.xx is your PRIVATE IP)

Hope this helps!

Upvotes: 0

Vishal
Vishal

Reputation: 1290

Have you try port number after IP address 27017 followed by ":".

Upvotes: 0

Related Questions