• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

How to fix MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk

January 2, 2024

How to Fix MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk

MongoDB is a popular NoSQL database that offers high performance, scalability, and flexibility. However, like any software, it can encounter errors that need to be resolved. One such error is the MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk. In this article, we will explore the causes of this error and provide step-by-step instructions on how to fix it.

Understanding the Error

The MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk occurs when a MongoDB replica set fails to elect a primary node. In a replica set, there are multiple nodes, with one designated as the primary and the others as secondary nodes. The primary node handles all write operations, while the secondary nodes replicate the data from the primary node.

When the primary node becomes unavailable or fails, the replica set should automatically elect a new primary node from the available secondary nodes. However, if the election process fails, the NotPrimaryNoSecondaryOk error is thrown.

Possible Causes

There are several potential causes for the NotPrimaryNoSecondaryOk error:

  • Network Issues: Network connectivity problems between the nodes can prevent the election process from completing successfully.
  • Node Configuration: Incorrect or inconsistent configuration settings across the replica set nodes can lead to election failures.
  • Node Availability: If all secondary nodes are unavailable or not reachable, the replica set cannot elect a new primary node.
  • Version Incompatibility: Running different versions of MongoDB on the replica set nodes can cause compatibility issues and prevent the election process.

Fixing the Error

To fix the MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk, follow these steps:

Step 1: Check Network Connectivity

Ensure that there are no network connectivity issues between the replica set nodes. Verify that the nodes can communicate with each other using the appropriate network ports. You can use the ping command or other network diagnostic tools to test the connectivity.

Step 2: Verify Node Configuration

Check the configuration settings of each node in the replica set. Ensure that the replSet parameter is correctly set to the same name across all nodes. Additionally, verify that the bindIp parameter is correctly configured to allow communication between the nodes.

Step 3: Check Node Availability

Ensure that at least one secondary node is available and reachable. If all secondary nodes are down or not accessible, the replica set cannot elect a new primary node. Troubleshoot any issues with the secondary nodes to restore their availability.

Step 4: Verify MongoDB Versions

Check the MongoDB versions running on each node. Ensure that all nodes are running the same version of MongoDB. If there are version mismatches, upgrade or downgrade the nodes to ensure compatibility.

Step 5: Force Election

If the above steps do not resolve the issue, you can force an election manually. Connect to one of the secondary nodes using the MongoDB shell and run the following command:

rs.stepDown()

This command forces the current primary node to step down and triggers a new election. The replica set should elect a new primary node, resolving the NotPrimaryNoSecondaryOk error.

Summary

In conclusion, the MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk occurs when a replica set fails to elect a primary node. This error can be caused by network issues, incorrect node configuration, node unavailability, or version incompatibility. By following the steps outlined in this article, you can effectively troubleshoot and fix this error. For more information about VPS hosting solutions, visit Server.HK.

Recent Posts

  • How to Configure SELinux in CentOS Without Breaking Your System (CentOS Stream 9/10 – 2026)
  • Managing Users and Permissions in CentOS Stream: Best Practices (CentOS Stream 9/10 – 2026)
  • How to Set Up Nginx on CentOS Stream for High-Performance Web Hosting
  • CentOS Stream Explained: Key Differences from CentOS Linux
  • How to Configure FirewallD in CentOS Stream: From Essential to Production-Grade

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot