Connection Failure Messages: No route to host and connection attempt failed
Symptom
An error is reported when you run the following command to connect to a DDS instance:
./mongo --host 192.168.1.6 --port 8635 -u rwuser -p xxxxxxxxx --authenticationDatabase admin --ssl --sslCAFile /root/ca.crt –sslAllowInvalidHostnames
Error message:
MongoDB shell version v3.4.17 connecting to: mongodb://192.168.1.6:8635/ 2019-09-19T09:38:36.954+0800 W NETWORK [thread1] Failed to connect to 192.168.1.6:8635, in(checking socket for error after poll), reason: No route to host 2019-09-19T09:38:36.954+0800 E QUERY [thread1] Error: couldn't connect to server 192.168.1.6:8635, connection attempt failed : connect@src/mongo/shell/mongo.js:240:13 @(connect):1:6 exception: connect failed
Possible Cause
- The instance port is incorrect.
- The DDS instance and ECS are not in the same region.
- The DDS DB instance and ECS are not in the same subnet.
Fault Locating
- Check whether the DDS instance and ECS are in the same region, security group, and subnet.
- Log in to the DDS console, click the instance name, and view information about the region, VPC, security group, and subnet on the Basic Information page.
Figure 1 Viewing instance network information
- Log in to the ECS console and click the ECS name. On the Basic Information page, view the region, VPC, security group, and subnet.
Figure 2 Viewing ECS network information
- Log in to the DDS console, click the instance name, and view information about the region, VPC, security group, and subnet on the Basic Information page.
- Check whether the instance port is correct and run the curl command to check whether the port is available.
- Click the instance name. On the Basic Information page, view the port of the instance.
Figure 3 Viewing instance port
- Run the curl command to check whether the port is available. The following is an example:
If the message "It looks like you are trying to access MongoDB over HTTP on the native driver port." is displayed, the IP address can be connected and port 8635 can be used for communication.
Figure 4 Command output
- Click the instance name. On the Basic Information page, view the port of the instance.
Solution
- Select an ECS that is in the same region, VPC, and subnet as the DDS instance to be connected. Alternatively, you can bind an EIP to the instance and connect to the instance over a public network.
- Ensure that the entered port is the same as the actual port displayed on the console.
Background Information
- If you connect to an instance over a private network, ensure that the region, VPC subnet, and security group of the ECS are the same as those of the DDS instance to be connected.
- If you cannot connect to an instance over a private network, you can bind an EIP to the instance and connect to the instance over a public network.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot