NodeJS or MongoDB limits responses to 1000?

October 8, 2015 1.3k views
Deployment Node.js API Ubuntu

I have a NodeJS application that connects to MongoDB. I use AngularJS on my front-end. The NodeJS app contains all my GET, POST, DELETE API. I have a GET request that returns my "Colleges" collection in full as a JSON response. This collection has 7771 documents and I only return the ID and Name as a JSON response.

When I run my application locally on my development environment, it works great and my GET's response is 7771 elements as JSON. When I uploaded my app and went live, I am seeing my GET's response is exactly 1000. What gives?

Does DigitalOcean put a limit on API responses? Or is it a configuration in my NodeJS or Mongod? If someone can point me to a configuration that would be great.

Note: I installed both NodeJS and Mongod using sudo-apt-get instead of the 1-click installs. I have a Ubuntu 14.4 droplet. I am newbie to cloud app development and hosting (doing it as a learning experience), so please forgive me if I'm my deployment choices are not standard.

P.S: I am still hosting NodeJS on port 3000 with a redirect on port 80. My GET requests are via AJAX to "/colleges" that may be going to port 80, not sure that makes a difference.

Re-routing done by:
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

  • Mongo version:

    app@dev:/etc$ mongod --version
    db version v2.4.9
    Thu Oct  8 15:03:50.491 git version: nogitversion
    app@dev:/etc$ mongo --version
    MongoDB shell version: 2.4.9

    NodeJS version:

    app@dev:/etc$ nodejs --version
  • This is my API code from NodeJS service:

    exports.listCollegesTypeahead = function(req, res) {
        db.collection('colleges', function(err, collection) {
            collection.find({}, {
                name: 1
                name: 1
            }).toArray(function(err, items) {

    This code returns all documents (7771) in my local box. In the Droplet that is in production, only 1000 documents are returned.

1 Answer

It turned out to be a versioning issue with my production droplet. The droplet was running nodejs and mongodb that was coming from the ubtuntu repository hosted by digital ocean. The restriction was possibly coming from running older versions and I was not able to figure out how to apt-get newer versions from the Trusty Trah repository hosted by digitalocean.

Upon updating to NodeJS v4.0.0 and MongoDB v3.0.6 on my Ubuntu server, I was able to see my GET request now returning 7771 records as expected.

After a apt-get remove and purge of "mongodb" and "nodejs", I ran the following to install NodeJS v4.1.2:

    curl -sL | sudo -E bash -
    sudo apt-get install -y nodejs

Next, I followed this guide to install mongodb 3.0.6

This fixed all the limit issues I was having in the app.

Have another answer? Share your knowledge.