• 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 MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk. In this article, we will explore the causes of this error and provide step-by-step solutions to fix it.

Understanding MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk

MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk occurs when a client attempts to read from a secondary node in a replica set, but there are no secondary nodes available. In a replica set, MongoDB maintains multiple copies of data across different nodes to ensure high availability and fault tolerance. The primary node handles all write operations, while the secondary nodes replicate the data and handle read operations.

When a client tries to read from a secondary node, MongoDB checks if there are any available secondary nodes to serve the request. If there are no secondary nodes available, MongoDB returns the NotPrimaryNoSecondaryOk error.

Possible Causes of MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk

There are several reasons why you might encounter the NotPrimaryNoSecondaryOk error:

  • No secondary nodes: If all the secondary nodes in your replica set are down or unavailable, MongoDB cannot fulfill read requests from secondary nodes.
  • Network issues: If there are network connectivity problems between the client and the secondary nodes, the client may not be able to reach the secondary nodes.
  • Incorrect configuration: If the replica set configuration is incorrect or misconfigured, MongoDB may not recognize the secondary nodes.

Fixing MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk

To resolve the NotPrimaryNoSecondaryOk error, follow these steps:

Step 1: Check Replica Set Status

First, verify the status of your replica set by connecting to the primary node using the MongoDB shell or a MongoDB client. Run the following command:

rs.status()

This command will display the current status of your replica set, including the state of each node. Ensure that all the secondary nodes are up and running.

Step 2: Check Network Connectivity

If all the secondary nodes are running, check the network connectivity between the client and the secondary nodes. Ensure that there are no firewall rules or network configurations blocking the communication.

Step 3: Verify Replica Set Configuration

Double-check the replica set configuration to ensure that it is correctly set up. Verify that each node’s hostname, port, and replica set name are accurate. You can use the following command to view the current replica set configuration:

rs.conf()

If you find any discrepancies or errors in the configuration, update it accordingly using the rs.reconfig() command.

Step 4: Add or Reconfigure Secondary Nodes

If you still encounter the NotPrimaryNoSecondaryOk error after following the previous steps, you may need to add or reconfigure secondary nodes in your replica set. Follow the MongoDB documentation to add new nodes or reconfigure existing ones.

Summary

In conclusion, MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk occurs when a client attempts to read from a secondary node in a replica set, but there are no secondary nodes available. This error can be caused by various factors, including the absence of secondary nodes, network issues, or incorrect configuration. To fix this error, you should check the replica set status, verify network connectivity, ensure the replica set configuration is correct, and add or reconfigure secondary nodes if necessary.

If you are experiencing MongoDB Error Code – 13435 – NotPrimaryNoSecondaryOk or any other MongoDB-related issues, consider reaching out to a reliable VPS hosting provider like Server.HK. They offer top-notch VPS solutions that can help you optimize your MongoDB deployment and ensure smooth operations.

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