Connect via Mobile Phone Hotspot

I have the same problem mentioned here. However, the provided solution does not work for me. I followed the instructions here on my Linux Mint (Debian) system and it has made no difference. I have re-started the laptop. My mobile wifi hotspot otherwise works without issue. My dhclient.conf includes the following 2 lines:

prepend domain-name-servers 8.8.8.8, 8.8.4.4;
prepend domain-name-servers 2001:4860:4860::8888, 2001:4860:4860::8844;

and these settings have also been applied in the network configuration GUI for the mobile hotspot connection in Linux.
I have also successfully added my mobile phone IP address to the ‘Network Access’ list in Atlas.
Attempting to connect to mongodb via VSCode gives me:
Unable to connect: connection <monitor> to 13.251.13.252:27017 closed
What else can I try? thanks …

Hi @freeross,

Whilst using the mobile hotspot, can you please try performing the initial basic network connectivity tests and provide the output for the cluster you are having trouble connecting to:

  1. ping one of the hosts (prefereably the PRIMARY):
/// example
ping cluster0-shard-00-00.ze4xc.mongodb.net
  1. telnet to one of the hosts on port 27017:
/// example
telnet cluster0-shard-00-00.ze4cx.mongodb.net 27017

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

Additionally, I would recommend to review the Troubleshoot Connection Issues documentation You may also find the following blog post regarding tips for atlas connectivity useful.

Regards,
Jason Tran

Hi @Jason_Tran,
Thanks for your response.
Both ping and telnet tests are successful for my primary cluster using my mobile phone hotspot from a terminal in my project directory on local Linux PC. However, attempting to connect to the same cluster via VSCode is still not working.
I reviewed the Troubleshoot Connection Issues documentation, but, as far as I can tell, the issues there (connection string config etc.) are not relevant in this instance as I can connect on my home based standard wifi connection with these setting.
I did notice that each time I connect the error message I get refers to a different IP:

Unable to connect: connection <monitor> to 18.140.187.114:27017 closed
Unable to connect: connection <monitor> to 13.251.13.252:27017 closed
Unable to connect: connection <monitor> to 52.221.43.169:27017 closed

However, I presume that is expected due to dynamic address allocation(?).

I tried the tool from blog post regarding tips for atlas connectivity and got:


FINAL STATUS OF CHECKS: 
 1. URL-CHECK:  	 Passed
 2. MEMBERS-CHECK:  	 Passed
 3. DNS-IP-CHECK:  	 Passed
 4. SOCKET-CHECK:  	 Passed
 5. DRIVER-CHECK:  	 Passed
 6. DBPING-CHECK:  	 Failed
 7. HEALTH-CHECK:  	 NotTested

RESULTING ADVICE: 
 - If the MongoDB deployment is an Atlas M0/M2/M5 tier cluster then via the Atlas console, in the 'Network Access' section, for the 'IP Access List' tab select to 'ADD CURRENT IP ADDRESS' which should be the address of this host machine  (DBPING-CHECK)
 - If using Atlas, via the Atlas console, in the 'Network Access' section, for the 'IP Access List' tab ensure this machine is listed in the access list, and if not, add it ('Add Current IP Address')  (DBPING-CHECK)
 - If using Atlas, via the Atlas console, check the cluster is NOT PAUSED and resume it if is paused  (DBPING-CHECK)
 - If not using Atlas to host the MongoDB deployment, check the firewall rules for the network hosting the deployment to ensure it permits MongoDB TCP connections on the configured ports - check NOT BLOCKED  (DBPING-CHECK)
 - Check any local firewalls on this machine and in your local network, to ensure that MongoDB TCP network connections to outside your network are NOT BLOCKED  (DBPING-CHECK)

I tried the suggestions and added my IP address as per my laptop network connection … still get same error (as above). Any other ideas? thanks again …

1 Like

@freeross in your first post, you did not mention you are getting the error while using VSCode. this is an important detail. I am not sure if it is relevant this time, but give us details of which extension is this you are getting the error.

anyways, “timeout” and “connection closed” are two distinct errors. the first one means there is no network toward the target. the second is, your case, from possibly a missing flag or something like that such that you connect but are not allowed to access.

the above is also true when you have a strict access setting in the “network settings” section. unless you have a static IP contract with your internet provider, your home modem or phone hotspot will have a different IP address anytime they are restarted. thus your connection to the database server will just be dropped.

go to your Atlas cluster and allow access from anywhere, “0.0.0.0”, to test if you can connect to the cluster that way.

PS: you have a static “name” to your cluster, but load balancing, primary changing, etc causes the IP change.

1 Like

@Yilmaz_Durmaz
The mobile hotspot connection works with 0.0.0.0.
To address the other points raised:
The extension is

MongoDB for VS Code v0.9.3

More Info

Released on
5/12/2020, 04:16:46
Last updated
4/27/2022, 07:10:42
Identifier
mongodb.mongodb-vscode

I’m unable to find a strict access setting in the “network settings” section in Atlas so I assume you mean on the laptop(?), however, I don’t find any reference to such a setting there either. I’m virtually certain I don’t have a static IP contract, but I’m adding the dynamically provided mobile phone hotspot address to ‘network access’ in Atlas ‘IP Access List’ and I still cannot connect via VSCode and get

DBPING-CHECK

error with the terminal app. Only 0.0.0.0 works currently. So the listed local DNS IPv4 address is not working even temporarily (before a restart etc.).
My db is at POC stage and is not of a sensitive nature so I can work with 0.0.0.0 when I am outside if necessary for now. But it would be preferable for the longer term to have a more robust solution. thanks again …

What you want to add to your Network Access List is the result of

This above does not work because the IP you get for your hotspot is not necessary the public access point of your cell provide or vpn provider.

3 Likes

Got it. Worked straight away. Thanks :+1: :grinning:

2 Likes

Good thing to know it was just a wrong WAN IP problem :wink:

by the way, with “strict network settings” I was referring to Atlas settings. but that could also be a problem from the hotspot, router, proxy, vpn, etc, yet they mostly cause “connection timeout” error :slight_smile: in your case, you were connecting but refused due to strict IP access.

one more thing about my “PS:” in my post above. it is about the IP change of the database server itself. it is a different thing than the IP change after hotspot/router restart or vpn/proxy changes.

1 Like