Problem connecting my database with my ip address (cpanel)

I don’t understand why when I connect my application locally in mongodb atlas it works but when I conncete the ip address of the site it doesn’t work.
I need your help

Hi @Ousmane_DIAW - Welcome to the community!

I don’t understand why when I connect my application locally in mongodb atlas it works but when I conncete the ip address of the site it doesn’t work.

If you’re able to connect to the Atlas cluster locally but not from cPanel, it may be possible that there is a cPanel configuration issue. However to confirm this, we’ll require more information which I have requested below.

I’ve not used cPanel in the past but it appears it is a hosting platform which means you may require them to allow outbound traffic to ports 27015 to 27017 as noted here. Additionally, you can see from the following post here that it appears the cPanel support (Namecheap?) unblocked port 27017 which resolved the issue. Hopefully this helps in your case. You may also want to ensure the client attempting to connect from the cPanel end is on the Network Access List for the project.

If further assistance is required after confirming the ports are not blocked, please provide the following:

  1. Method of connection (mongosh, MongoDB driver, driver version)
  2. Full error message / output when attempting to connect from cPanel
  3. The output from running a ping to one of the hosts (prefereably the PRIMARY) from the cPanel client:
/// example
ping cluster0-shard-00-00.ze4xc.mongodb.net
  1. The output from running a telnet to one of the hosts on port 27017 from the cPanel client:
/// example
telnet cluster0-shard-00-00.ze4cx.mongodb.net 27017

Note: You can find the hostname in the metrics page of your cluster

Regards,
Jason

2 Likes

Hi
I followed your instructions: port 27017 is not blocked and the ip address is on the network access list.

Here is the information you requested:

  1. Connection method: MongoDB driver version 4.4.1
  2. Error message
  3. [senechoicetours-shard-00-01.ovhwy.mongodb.net:27017]

Thanks in advance

I followed your instructions: port 27017 is not blocked and the ip address is on the network access list.

Thanks for providing those details. Could you provide the output from the ping and telnet commands from that client? I cannot see the output from either from the screenshot you attached? This will at least help confirm some level of connectivity from the cPanel client to the Atlas cluster’s node(s).

  1. [senechoicetours-shard-00-01.ovhwy.mongodb.net:27017]

If the hostname:port of the PRIMARY is the value you provided here, then the commands that should be run from the cPanel client are:

ping senechoicetours-shard-00-01.ovhwy.mongodb.net
telnet senechoicetours-shard-00-01.ovhwy.mongodb.net 27017

Regards,
Jason

1 Like

Hi
I have also problem with connect mongo db to cpanel.
I have project that run locally but not work on c panel ,
What can I do that its work ?
Thank

Hi @T_B1 - Welcome to the community.

I would advise taking a look at the following post’s discussion that also mentions cPanel connection attempts and the associated solutions involving port opening from the cPanel side. I presume since you are able to connect locally, that there may be configuration from cPanel’s end that needs to be done for connectivity.

Regards,
Jason

Thank
But can u tel me what is Namecheap that they spoke about it?
I didnt understand how it connect to C panel
Thank

PING cluster0-shard-00-00.ze4xc.mongodb.net.secureclouddns.net (51.210.156.16) 56(84) bytes of data.
64 bytes from server61.secureclouddns.net (51.210.156.16): icmp_seq=1 ttl=54 time=219 ms

telnet: command not found

@Aditya_Sharma8,

I would try connecting from a client hosted your own machine that has access to the cluster over the public internet first. Make sure you’ve allowed the IP address so that you can connect from your own machine and then use something like monogosh or MongoDB Compass. If you can connect it would generally mean the Atlas cluster is fine in which case you might want to contact the cPanel support team with regards to why the client(s) there are unable to connect.

I have the same problem with Cpanel
Everything is working on localhost and cyclic.sh.
But, if I try to run the same simple app it doesn’t connect.

err = new ServerSelectionError();
^
MongooseServerSelectionError: Could not connect to any servers in your MongoDB A tlas cluster. One common reason is that you're trying to access the database fro m an IP that isn't whitelisted. Make sure your current IP address is on your Atl as cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist /
at _handleConnectionErrors (/home/marshaltrans/marshal_app/node_modules/mong oose/lib/connection.js:792:11)
at NativeConnection.openUri (/home/marshaltrans/marshal_app/node_modules/mon goose/lib/connection.js:767:11) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(3) {
'ac-dp3uge5-shard-00-00.nerrton.mongodb.net:27017' => ServerDescription {
address: 'ac-dp3uge5-shard-00-00.nerrton.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 111847082664,
lastWriteDate: 0,
error: MongoNetworkError: unable to get local issuer certificate

I’ve opened the access to cluster.
Hosting support checked connection, and it’s ok.

I’ve bought VPS, and all troubles has gone.

@Ivan_Rocket Yes we have also brought the VPS

Thanks for the help @Jason_Tran

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.