Could not connect to MongoDB on the provided host and port

Hi,

I am getting error “Could not connect to MongoDB on the provided host and port” while try connecting to Mongo Compass. I have tested the firewall restriction and it’s working fine. However, I am not able to access Mongo Compass.

Please suggest. Thank you

Hostname: cluster0-shard-00-00-jxeqq.mongodb.net
Username: m001-student
Password: m001-mongodb-basics
Replica Set Name: Cluster0-shard-0
Read Preference: Primary Preferred

Fuad

1 Like

Hi Muhammad_Fuad_22046,

Have your tried everything mentioned in this thread: About the Chapter 1: Compass Connection ?

If you have, I would recommend restart Compass, try login again and let me know if the issue is still there.

Thanks, Kanika

May be your port is used by other application or blocked

Hi

I am not to connect to atlast -“MongoDB not running on the provided host and port”
ping is working but telnet connection failed.

i am using compass stable version.

Hi Avinash_41186,

If your ping is working fine that you means you can access the host (cluster0-shard-00-00-jxeqq.mongodb.net), but there is problem connecting to 27017 port, please check on clicking this. It should show something like this:

Outgoing port tester

This server listens on all TCP ports, allowing you to test any outbound TCP port.

You have reached this page on port 27017 .

Your network allows you to use this port. (Assuming that your network is not doing advanced traffic filtering.)

Network service: unknown

Also, can you go to your browser and try http://cluster0-shard-00-00-jxeqq.mongodb.net:27017/ . The output should be:

It looks like you are trying to access MongoDB over HTTP on the native driver port.

If you are still not able to connect, please check if this port is getting used by any other application. Make the port 27017 free and restart Compass and try logging in again.

For any other error, I would recommend going through this thread: About the Chapter 1: Compass Connection

Thanks, Kanika

Hi Kanika,

I checked it, and got the same response


Outgoing port tester

This server listens on all TCP ports, allowing you to test any outbound TCP port.

You have reached this page on port 27017 .

Your network allows you to use this port. (Assuming that your network is not doing advanced traffic filtering.)

Network service: unknown

It looks like you are trying to access MongoDB over HTTP on the native driver port.

and port state is listening

but still a am not able to connect it.

now, I am getting Java script error while restarting compass -“Object has been destroyed at Function…”

Hi Avinash_41186,

You have run into this known bug: Compass - JavaScript error at startup - “Object has been destroyed”

You might need to reinstall Compass, download it here

I am sorry for the inconvenience caused.

Thanks, Kanika

Hi @Tash_33746,

I believe so. However, I have tested using other port on PowerShell and it’s successfully.
However, when I trying to connect using compass, it’s not able to connect.

I am also getting the same error message and also tried to restart the compass but still the issue persist .Please help.

Hi Prince_66590,

Please download and install latest version i.e. 1.16.1. It has the javascript issue fixed.

Download from here.

Kanika

1 Like

Hi @Kanika
I am getting following error
“An error occurred while loading navigation: ‘not master and slaveOk=false’: It is recommended to change your read preference in the connection dialog to Primary Preferred or Secondary Preferred or provide a replica set name for a full topology connection.”
Kindly help me
Thanking you in advance

I am seeing the same problem. I’ve checked the connection details three times and they match those specified in the lecture notes. Compass shows me a list of DBs down the left hand side, but clicking on them only repeats the message that @Reyaz_46528 is reporting. I have disconnected and reconnected multiple times.

Hi @Tom_11934
use following details for connection. Its working for me now.

Hostname: cluster0-shard-00-00-jxeqq.mongodb.net
Username: m001-student
Password: m001-mongodb-basics
Replica Set Name: Cluster0-shard-0
Read Preference: Primary Preferred
Favorite Name: M001 RS

Thank you. I think these are the same details shown in the lecture notes, but they are working from me now.
I was getting the same error, but then I completely exited Compass and opened it again, and now I can see the databases and their contents.

Back to work on the course…

Hi Reyaz,

Please check all the possible solutions mentioned in this post here.

Let me know if it doesn’t work!

Kanika

Thank you @Kanika
I am able to connect properly.

1 Like

MongoDB Compass Version 1.17.0
Try selecting

  • SSL [ Unvalidated(insecure) ]

I am still getting “Could not connect to MongoDB on the provided host and port” tried all the steps in MongoDB Swift Driver 1.0.0-rc0 released - #2 by Jonny

Also [ follwing url works from my laptop. but error when connecting from compass.

http://cluster0-shard-00-00-jxeqq.mongodb.net:27017/

Which version you are using
Is connection working from mongo shell
Rule out all possibilities IP whitelist,anti virus,firewall,port block etc
Did you try from another location or machine
Are you trying from office or home?

Issue persists for me as well

The link works for me: http://cluster0-shard-00-00-jxeqq.mongodb.net:27017/

output: It looks like you are trying to access MongoDB over HTTP on the native driver port.

But the ping command in cmd of windows 10 gives below error:

ping cluster0-shard-00-00-jxeqq.mongodb.net

"Ping request could not find host cluster0-shard-00-00-jxeqq.mongodb.net. Please check name and try again "