Couchbase, ExpressJS, AngularJS, Node.js (CEAN) Stack

Create A Full Stack App Using Node.js & Couchbase Server

Previously I wrote about how to create an AngularJS application with PouchDB and Couchbase.  The way I demonstrated is of course one way to accomplish the job of using Couchbase in a web application.  This time around we’re going to take a look at creating a full stack application using the Couchbase, ExpressJS, AngularJS, and Node.js (CEAN) stack.

You might be familiar with the MongoDB, ExpressJS, AngularJS, and Node.js (MEAN) stack, but I’m going to show you that this is just as possible with Couchbase and even easier to do.

We’re going to see how to install and configure all four of the CEAN stack services as well as make a very simple application out of them.

The whole setup process doesn’t take long so we’re going to run through it real quick.

Installing Couchbase Server

Let’s start with installing our database, Couchbase Server.  Head over to the downloads section of the Couchbase website and get the latest installation for your computer, whether it be Mac, Windows, or Linux.

Install the file that you downloaded and launch Couchbase Server.  Upon first launch it should take you through a configuration wizard.  The wizard takes about two minutes to complete.

Creating A Bucket And Index

Couchbase stores all NoSQL documents in what’s called a bucket.  We’ll need to create one called restful-sample in order to continue in the application.  From the Data Buckets tab of your Couchbase administrative dashboard, choose to Create New Data Bucket and name it appropriately.

Couchbase Dashboard Create Bucket

With the bucket created, we need to create a primary index on it.  This will allow us to run N1QL queries against the data.  You’ll see what they are and why they are beautiful deeper in this tutorial.

Run the Couchbase Query Client (CBQ) from the Terminal or Command Prompt.  On a Mac, it is found at the following path:

On a Windows computer it is found at the following path:

With CBQ open, run the following statement to create a primary index:

Our Couchbase Bucket is now ready to go!

Installing Node.js

Now we’re going to install Node.js.  Although we won’t see it in this step, the Node Package Manager (NPM) included with Node.js will be used to download ExpressJS and its dependencies.  Head on over to the Node.js website and download whatever version is appropriate for your operating system.

Install Node.js however you typically would based on your operating system.

Setup Your Node.js Project

Create a new directory, maybe on your desktop, called CEAN.  Using the Terminal (Mac and Linux) or Command Prompt (Windows), run the following with CEAN as your current working directory:

Answer all the questions to the best of your ability, or just create a file called package.json with the following contents:

Since we have NPM working through the Node.js installation, we need to install ExpressJS and a few other dependencies locally to our project.  From the Terminal or Command Prompt, run the following command:

Let’s break down what we just installed.  The body-parser dependency will allow us to make POST requests to our backend API.  The couchbase dependency will allow you to communicate from application server to Couchbase Server.  The express dependency of course allows us to use the ExpressJS framework and the uuid dependency will allow us to generate unique ids later in our project.

Before we bring setup to a close, lets define our project structure.  Go ahead and create the following files and directories:

—-> routes
——–> routes.js
—-> models
——–> recordmodel.js
—-> public
——–> js
————> app.js
——–> css
——–> templates
————> item.html
————> list.html
——–> index.html
—-> app.js
—-> package.json
—-> config.json

We’ll be adding other libraries and style sheets, but above is everything we’ll be creating.

The Project Back-End

The back-end will be responsible for serving data to our front-end (AngularJS).  It is endpoint based making separation between front-end and back-end easier.

Configuring The Server

All our server configuration will be in the app.js file found at the root of our project.  However, to keep our project clean, we’re going to put all our constant variables in their own file.  This fille will be called config.json and it will contain the following:

We essentially only have two constants for this project.  What server we plan to use and what bucket we want to use.  A bucket in Couchbase terms is a collection of NoSQL documents.

Open app.js at the root of your project and include the following code:

Let’s break down what is happening here.  First off we are requiring all the dependencies that we downloaded with NPM into our project.  We are then telling the application server that we want to accept POST requests with JSON bodies as well as URL encoded data.

Here we connect to the Couchbase cluster and open a particular bucket, both defined in our config.json file.  This opened bucket is assigned to a global variable through the module.exports command.

The above line will allow us to place HTML, JavaScript and other front-end files in our project.  The front-end and back-end will still communicate over requests, but the front-end code is still going to be bundled with our project.

Finally we are including our routes/routes.js file which will contain paths to each of our endpoints and the server listener.

Designing Our Database Model And Functions

Before we set up our routes, let’s determine some functions for communicating with the database.  All of these functions will go into the RecordModel class found in the models/recordmodel.js file.  These functions will be responsible for inserting, updating, retrieving, and deleting data from Couchbase.  Pretty much your CRUD basics.

Let’s start by laying the foundation to this models/recordmodel.js file.  Open it and add the following:

You can see above that we are requiring the uuid dependency that we downloaded as well as the app.js and config.json files from the root of our project.  This is because we plan to use all these.

Now let’s break down all the functions starting with the save function.  In your models/recordmodel.js file, add the following function before the module.exports = RecordModel; line:

What is going on here?  Well we are accepting an object of data and a callback passed in from the soon to be created parent route.  We are extracting only the data elements we need from the data variable and we are constructing a document key to be used.  This save function will handle both updates and inserts (upsert) so keys are very important.  Basically, if a document id was passed from the route, use it, otherwise create some unique value and use that.  Upsert will decide whether or not we should insert or update.

Depending on the how the upsert function responds is how we make use of the parent callback function.

With save out of the way, lets take a look at the getByDocumentId function for fetching a specific document.  In your models/recordmodel.js file, add the following:

This function again is accepting two parameters from the parent endpoint, a document id and a callback.  However, this time we are using a very SQL-like statement referred to by Couchbase as N1QL.  It is a parameterized query to prevent injection attacks, but it essentially just finds any NoSQL document where the document key matches the value passed in the function.

The next function, delete, is pretty simple.  Inside the models/recordmodel.js file add the following:

We’re just passing a document id and a callback and making use of the Node.js SDK for Couchbase.  Very simple and nothing special.

Finally our last function, getAll, which will get all documents from our Couchbase bucket:

Again, we’re using N1QL here because it is very convenient for getting a bunch of documents back.

Wew! We now have all the logic in our CEAN application that interfaces with Couchbase Server.  This leaves us to designing our endpoints and font-end.

Creating API Route Endpoints

Everything we do here will be in the routes/routes.js file.  The foundation to this file will look like the following:

Every route will end up inside of the appRouter function.  Let’s go in the same order we did for the class functions, starting with the save route:

When the user (or front-end) hits the /api/save endpoint with a POST request, the above will happen.  We first make sure the POST body contains a firstnamelastname, and email, otherwise we return an error.  If those conditions are met then we call the save function of our RecordModel class.  The callback is passed and depending on what the child function returns, is what we return back to the user (or front-end).

With save out of the way, let’s look at the get endpoint for getting a particular document from the database:

When the front-end hits the /api/get endpoint with a GET request, the above will happen.  We first make sure the GET query contains a document_id and if that condition is met then we can proceed to calling the getByDocumentId function of our RecordModel class.

I’m sure you can see a trend here in our endpoint design.

Moving on, we want to make an endpoint for deleting data.  In the routes/routes.js file add the following function:

If a POST request to the /api/delete endpoint is made above, we first confirm that the document_id exists in the POST body.  If it does, then call the delete function of the RecordModel class.

Finally we have our last endpoint.  The last endpoint is responsible for returning all documents that exist in the database.  It can be seen in the following code:

There are no requirements above.  As long as a GET request is made to the /api/getAll endpoint, data will be returned.

Our back-end is done.  We can celebrate now!  Not exactly, we still need a front-end to communicate to it.  Any front-end will work, but in this CEAN stack we’re going to be using AngularJS.

The Project Front-End

The front-end will be responsible for requesting data from our back-end (Node.js and Couchbase Server).  It makes HTTP requests to the back-end allowing for better separation and flexibility between the front-end and back-end.

Including All Third-Party Libraries And Styles

The front-end we’re making is of course using AngularJS, but it is also using the AngularJS UI-Router library as well as Twitter Bootstrap.  The first thing we want to do is download everything.

After downloading everything, place the minified (.min.js) files in your project’s public/js directory.  Place all CSS files in your project’s public/css directory, and place all fonts in your project’s public/fonts directory.

Now everything can be included in your projects public/index.html file.  Open it and include the following:

You may be wondering what ng-app="recordsapp" is or what <div ui-view></div> is.  Don’t worry, that is coming soon.

Creating The AngularJS Foundation

Inside your public/js directory you should have an app.js file.  Go ahead and add the following foundation code:

You can see here that we’ve named our module recordsapp which relates to what we saw in the public/index.html file.  We’ve also injected the ui.router and built functions for our .config and .controller.

Configuring The AngularJS UI-Router

If you’re unfamiliar with the AngularJS UI-Router, it is a wonderful library for adding multiple screens (views) to your front-end application.  All configuration for these views will end up in our config function in the public/js/app.js file:

Essentially we’re creating two views.  We are creating a list view and a view for adding or editing items of the list.  Each of the routes points to a particular controller and template file.  Both routes point to the MainController that we’ll see soon, but each point to either a public/templates/list.html file or public/templates/item.html file.

By default, the list view will show through the $urlRouterProvider.otherwise("list"); line.

Designing Our View Routes

We know which template files we need to work on now as explained by the AngularJS UI-Router configuration.  Starting with the public/templates/list.html file, add the following code:

Essentially we have a table that loops through each object within a particular object to populate the table.  Functions like fetchAll and delete are still unknown at this point, but they are coming.  If you take a look at the ui-sref items in the code you’ll notice they are referring to particular UI-Router states.  One of which passes in an optional parameter containing the document key.  You’ll see how it’s used soon.

The second template we want to look at is the public/templates/item.html file:

This file is nothing more than a form.  When the success button is pressed, a save function is called.  We haven’t created it yet, but it is coming.

Adding Our Controller Logic

The last part of our front-end is all of the application logic to fuel the visuals.  Inside your project’s public/js/app.js file, add the following to your controller:

That is a lot of $http requests, and that’s the point!  The front-end of this stack is only suppose to request data from the back-end.  It makes it very modular.

Running The Application

At this point your Couchbase Server should be up and running.  From the Command Prompt or Terminal, run the following with the project as your current working directory:

If you visit http://localhost:3000 from your web browser you should have a fully functional CEAN stack application.

CEAN Stack Simple Application

Above is what your application should look like.


You just saw how to build a full stack CEAN stack application.  Our code was short, clean, and very easy to understand thanks to the beauty of the Node.js SDK for Couchbase.

If you’re interested in the full source code to this project, it can be downloaded from the Couchbase Labs GitHub repository.

Nic Raboy

Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.

  • Thank you Nic for this and other previous useful contributions. If you have the time and inclination won’t you please look into the use of “deep links” within the Ionic Framework. It is increasingly of compelling interest and importance.

  • HI Nic, once again great article, having looked as Ionic, Pouch and CouchDB syncing would you suggest this stack as a route into providing the middle layer giving the ability for multiple users documents on one couchdb database. Having read up on couchdb it seems that this functionality is on the road map, but currently a middle layer between the pouch and couchdb sync is required so that multiple users can all sync their individual pouchdb’s to one couchdb without each user pouchdb contianing all of the couchdb’s documents. Apologies if I have gone wrong in my research. Your tutorial looks spot on to give me the web front end to the mobile app I have in mind!

    • Careful not to confuse CouchDB and Couchbase. They are two very different database products. My PouchDB post and this one, both refer to Couchbase which is superior in features and scalability vs CouchDB. Both open source.

      When using PouchDB with Couchbase you need to use the middleman product “Sync Gateway”. It handles the channeling of your data. When using the RESTful approach like demonstrated here, you don’t need the Sync Gateway because the RESTful API (Node.js) will handle all your data management.

      I am trying to give many alternatives so that way you can pick the best approach for your needs 🙂

      Does all this make sense?

      • Hi Nic, thanks for the clarification. In your experience when dealing with a per user basis and mobile sync would couchbase be the tool of choice? I have to admit I’m trying to avoid an API so I dont have to write the sync logic – sorry for asking very specific questions

        • If your intention is sync I’d use the Couchbase Sync Gateway.

  • willard Chingarande


    Thanks for the blog. I am getting syntax error on creating the primary index using CREATE PRIMARY INDEX ON restful-sample USING GSI;

    Thank you

    • Can you please paste your full logs / error?

      Also, what build of Couchbase Server are you using and are you using Community Edition or Enterprise Edition?


      • willard Chingarande

        Version: 4.0.0-4051 Enterprise Edition (build-4051)

        • It looks like you are using single quotes on the bucket name. When a bucket name contains a hyphen you need to use back ticks.

          Let me know if that corrects it for you.


          • willard Chingarande

            Thanks it worked

          • No problem!

  • Nathan Lodge

    Thanks, Nic!

  • Dilip K Singh

    Hi Nice article..
    I tried your blog and try to create demo project but facing issue when run > node app.js on my cmd prompt..
    Here got an error “angular is not defined’ please help me..
    I am new on couchbase, Node.js
    I am waiting for your response

    • You get this Angular error in your command prompt? If Angular is throwing errors it should be in your browser console, not Node.js. Please clarify and paste the full log.


      • Dilip K Singh

        yes it’s throwing error in command prompt.. When run > node app.js

        • You’ll need to paste everything that appears in the command prompt if you want help.

  • John Galt

    Nice work Nic, this is great. May I suggest an even more memorable comparison to the “MEAN Stack”? I recommend Couchbase call their superior stack “OCEAN”. It is more complete and much easier to remember. I mean what is a ‘CEAN’ anyway?
    ‘OCEAN’ === ‘Ottoman-Couchbase-Express-Angular-Node’.

    You heard it from me first 😉

    • Dang, that is great! I’m going to pass this around internally for anyone who uses Ottoman in the mix.

      Great suggestion!

    • Corey Quillen

      Or the “CLEAN” stack because most deployments probably use Linux: “Couchbase-Linux-Express-Angular-Node”.

      • John Galt

        yeah, what you say is true. I had thought of CLEAN but admit I couldn’t work the “L” in there gracefully. Clever.

  • Morgan Hayes

    Nic, i am getting an error that app is not defined in route.jd line 9. I double checked with your github code and i match. any ideas?

    • Morgan Hayes

      Nic, I have copied in you github code folder, to start clean. how do i get this app to work with my server on a differnet machine. i have the address and bucket name. I get this error. please let me know if you have any ideas. thanks

      “Error: cannot perform operations on a shutdown bucket    at Bucket._maybeInvoke (C:\CEAN-apps\ran-app\node_modules\couchbase\lib\bucket.js:853:11)    at Bucket._n1ql (C:\CEAN-apps\ran-app\node_modules\couchbase\lib\bucket.js:697:8)    at Bucket.query (C:\CEAN-apps\ran-app\node_modules\couchbase\lib\bucket.js:742:17)    at Function.RecordModel.getAll (C:\CEAN-apps\ran-app\models\recordmodel.js:64:8)    at C:\CEAN-apps\ran-app\routes\routes.js:46:21    at Layer.handle [as handle_request] (C:\CEAN-apps\ran-app\node_modules\express\lib\router\layer.js:95:5)    at next (C:\CEAN-apps\ran-app\node_modules\express\lib\router\route.js:131:13)    at Route.dispatch (C:\CEAN-apps\ran-app\node_modules\express\lib\router\route.js:112:3)    at Layer.handle [as handle_request] (C:\CEAN-apps\ran-app\node_modules\express\lib\router\layer.js:95:5)    at C:\CEAN-apps\ran-app\node_modules\express\lib\router\index.js:277:22n”

      • It sounds like (a) your instance of Couchbase Server is not running or the bucket has not been created or (b) the wrong hostname is being used in the configuration or there is a firewall issue.

        Can you validate all of the above and report back?


        • Morgan Hayes

          the bucket exists, i have used it with pouchdb and see it in the couchbase console. Do i use the same address as i used in my pouchdb app? also i noticed your app uses 8091 port and i use 4984 with Pouchdb.

          • PouchDB connects to Sync Gateway which operates on port 4984. The Node.js SDK connects directly to Couchbase Server which operates on port 8091.

            Attempting to connect to Couchbase Sync Gateway from Node.js will not work.

            Want to validate your setup and report back?

          • Morgan Hayes

            Thank you for your response, Love your tutorials. I do have sync-gateway running on the port you stated above. For this app would i use the same ip and port as when i log in to the console (with 8091)?
            I get similar error when i use the same address as the console. Just to clarify, i am on my desktop using your program. The couchbase server is on another machine (server). I can log in to the CB console from my desktop with password to see my bucket with the same name i have in the code. The only code i have changed is the config.js file and added bootstrap files.

            Error: cannot perform operations on a shutdown bucket    at Bucket._maybeInvoke (C:\CEAN-apps\ran-app\node_modules\couchbase\lib\bucket.js:853:11)    at Bucket._n1ql (C:\CEAN-apps\ran-app\node_modules\couchbase\lib\bucket.js:697:8)    at Bucket.query (C:\CEAN-apps\ran-app\node_modules\couchbase\lib\bucket.js:742:17)    at Function.RecordModel.getAll (C:\CEAN-apps\ran-app\models\recordmodel.js:64:8)    at C:\CEAN-apps\ran-app\routes\routes.js:46:21    at Layer.handle [as handle_request] (C:\CEAN-apps\ran-app\node_modules\express\lib\router\layer.js:95:5)    at next (C:\CEAN-apps\ran-app\node_modules\express\lib\router\route.js:131:13)    at Route.dispatch (C:\CEAN-apps\ran-app\node_modules\express\lib\router\route.js:112:3)    at Layer.handle [as handle_request] (C:\CEAN-apps\ran-app\node_modules\express\lib\router\layer.js:95:5)    at C:\CEAN-apps\ran-app\node_modules\express\lib\router\index.js:277:22n

          • In the Node.js application you would supply the IP of the remote server and use port 8091. In the config.json file you might also try the following:

            If neither works you may have a firewall issue where your local computer cannot reach Couchbase Server or the server which houses Couchbase Server may be rejecting its connection. Both scenarios would likely be firewall related.


          • Morgan Hayes

            thanks Nic, I found a suggestion to increase the bucket.operationTimeout That has seemed to help.
            Now i have an error with undefined (when i debug i see the ID as undefined in the $ when i attempt to “add item”

            TypeError: Cannot read property 'upsert' of undefined    at (C:\CEAN-apps\ran-app\models\recordmodel.js:32:7)    at C:\CEAN-apps\ran-app\routes\routes.js:25:21    at Layer.handle [as handle_request] (C:\CEAN-apps\ran-app\node_modules\express\lib\router\layer.js:95:5)    at next (C:\CEAN-apps\ran-app\node_modules\express\lib\router\route.js:131:13)    at Route.dispatch (C:\CEAN-apps\ran-app\node_modules\express\lib\router\route.js:112:3)    at Layer.handle [as handle_request] (C:\CEAN-apps\ran-app\node_modules\express\lib\router\layer.js:95:5)    at C:\CEAN-apps\ran-app\node_modules\express\lib\router\index.js:277:22    at Function.process_params (C:\CEAN-apps\ran-app\node_modules\express\lib\router\index.js:330:12)    at next (C:\CEAN-apps\ran-app\node_modules\express\lib\router\index.js:271:10)    at serveStatic (C:\CEAN-apps\ran-app\node_modules\serve-static\index.js:74:16)n

          • Are you sure that bucket.operationTimeout truly solved the issue? The error is saying that the db of db.upsert is undefined. It is imported via the following:

            If the bucket wasn’t truly opened or you forgot the import, you’ll get that error.

            Add this to your code to get more error information about your bucket operations:


          • Hey Nic, I’m also running in the same issue. On debugging further this is the response I get –

            Since my instance and bucket is all running and the app is also working for a sample bucket, so it’s definitely the timeout issue. Though I’m not sure how and where I can fix that.

          • What version and edition of Couchbase Server and what version of the Couchbase Node.js SDK?

          • Couchbase Server – Version: 4.5.0-2203 Enterprise Edition
            Couchbase Node – 2.1.6

          • Couchbase Server 4.5 is still in beta. I’m wondering if there was a bug introduced.

            Let me follow up with the development team to see if there are any known bugs with the Node.js SDK. In the mean time you may consider 4.1. I use it and it works fine.

          • Hey Nic, as you have suggested I’ve switched back to version #4.1.1
            Now there appears to be one more problem. When I tried to provision my cluster and bucket I ran into the following error –

            {“errors”:{“storageMode”:”Found unsupported key storageMode”}}

            This is the URL I’m pointing at –

            and StorageMode is forestdb, but it seems version #4.1.1 doesn’t support that. Here is Couchbase documentation for above version, which has no details listed for v 4.1.1.


          • And yes about the above error no it’s not resolved after updating the version. I’ve tried with this repo too –

            However the response is bit weird. First time when I run the app I get the above error of timeout, however when I re-exectue, it just works fine.

          • So you’re trying to do things that I didn’t mention in this particular tutorial. Can you tell me if you can get the tutorial working as it is, without any extra things? We need to take a step back.

          • Yes the tutorial as it is working great for me, however since I’ve my own requirements and application structure, I’ve even tried injecting code as it is in my app. Which was giving me above error. So to debug it further I’ve divided this line of code you have written –

            module.exports.bucket = (new couchbase.Cluster(config.couchbase.server)).openBucket(config.couchbase.bucket);

            PS – How you are formatting the code block in these comments?

          • It worked!!!
            I have done everything I can on v4.5.0 and v4.1.1 EE (mac EL Capitan), but it just didn’t work. Then I finally switched to v4.0.0 CE and the exact same code worked like a charm.

          • Thanks for following up. I’m following up internally at Couchbase on this one to see if there are any known bugs. I’ll report back.

          • This is what working for me –

            const myCluster = new couchbase.Cluster((endPoint), err => {
            if(err) debug(“NEW CLUSTER –> “, err);
            myCluster.operationTimeout = 120 * 1000;

            Though I wonder if that is really the right thing to do. It’s most probably just bypassing the problem instead of resolving it.

    • Did you forget to do npm install to grab all the project dependencies?

  • Sup Nic? Where’s the Couchbase Query Client on linux? :/

  • Hello Nic, may I ask what this error is about?

    Error: consistency and consistentWith must be use exclusively.
    at N1qlStringQuery.consistency (/var/www/html/couchtest/node_modules/couchbase/lib/n1qlquery.js:82:11)
    at Function.RecordModel.getAll (/var/www/html/couchtest/models/recordmodel.js:50:49)
    at /var/www/html/couchtest/routes/routes.js:46:21
    at Layer.handle [as handle_request] (/var/www/html/couchtest/node_modules/express/lib/router/layer.js:95:5)
    at next (/var/www/html/couchtest/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/var/www/html/couchtest/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/var/www/html/couchtest/node_modules/express/lib/router/layer.js:95:5)
    at /var/www/html/couchtest/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/var/www/html/couchtest/node_modules/express/lib/router/index.js:330:12)
    at next (/var/www/html/couchtest/node_modules/express/lib/router/index.js:271:10)

  • Mounika Ch

    Getting an error ” cannot read property ‘request_plus’ of undefined.

  • Dan Damian

    Hy Nic,

    Thanks for the great tutorial!
    I’m also having a problem, and though I keep searching for the error for two days, found nothing till now.

    My context:
    nodejs 6.10.0 LTS running on macOS Sierra 10.12.3 connecting to a AWS hosted Couchbase CE 4.5.0-ubuntu14.04_amd64 running on a Ubuntu 14.04.5 LTS.
    AWS security groups configured ok as I’m able to connect to Couchbase’s Web Admin Console.

    I’ve created the bucket and the index as you indicated, but when I just start the app and the model asks for getAll I get this error:

    Error: An unknown N1QL error occured. This is usually related to an out-of-memory condition.

    My mac’s firewall is turned off.
    My config.json looks like this:

    “couchbase”: {

    Any help greatly appreciated!

    • What are the specs of your AWS instance? Can you execute the query via Query Workbench in the Couchbase admin dashboard? Does it still crash?

      Let me get more information from you. It is possible your AWS node is too small.


      • Dan Damian

        Yes, I can execute the query from the Admin Web Console. I have a e t2.small with 4gb ram, 1 vcore and something like 8gb storage. It wouldn’t let me install it if my server would have lesa than 4gb ram.

        • For the AWS instance did you use a Couchbase image or did you use an image and then install Couchbase on it? I’m wondering if you haven’t opened all the necessary ports. 8091 is the admin port, but you’d also need 8092 and 8093.

          If that doesn’t solve it, you might post in the Couchbase forums.

          • Dan Damian

            For AWS I’ve used an Ubuntu 14.04.5 LTS image, and then installed Couchbase 4.5.0 CE for Ubuntu..
            I’ve made also the changes in the Security Group so that 8091, 8092 and 8093 and also Ping are allowed from my second machine, which is t2.micro where NodeJs runs.
            Now, when I run the first N1QL (for retrieving the list with results…) i get the error bellow:

            Error: cannot perform operations on a shutdown bucket
            at Bucket._maybeInvoke (/home/ubuntu/CEAN/node_modules/couchbase/lib/bucket.js:1064:11)
            at Bucket._n1ql (/home/ubuntu/CEAN/node_modules/couchbase/lib/bucket.js:717:8)
            at Bucket.query (/home/ubuntu/CEAN/node_modules/couchbase/lib/bucket.js:949:17)
            at Function.RecordModel.getAll (/home/ubuntu/CEAN/models/recordmodel.js:59:8)
            at /home/ubuntu/CEAN/routes/routes.js:45:19
            at Layer.handle [as handle_request] (/home/ubuntu/CEAN/node_modules/express/lib/router/layer.js:95:5)
            at next (/home/ubuntu/CEAN/node_modules/express/lib/router/route.js:137:13)
            at Route.dispatch (/home/ubuntu/CEAN/node_modules/express/lib/router/route.js:112:3)
            at Layer.handle [as handle_request] (/home/ubuntu/CEAN/node_modules/express/lib/router/layer.js:95:5)
            at /home/ubuntu/CEAN/node_modules/express/lib/router/index.js:281:22

            In my config.json I’ve used for my Couchbase server all the variants:
            public dns name, public ip (even though the public ones didn’t make sense, but anyway), private dns name, private ip. For all of them I’ve got the same results… 🙁

          • For your host, instead of doing:


            Try doing


            If that doesn’t work, It sounds like it is probably some configuration issue with your Amazon instances. You might want to post in the Couchbase forums for better help.


  • Hamseni k

    Thanks for your great tutorial, how to check the document is already exits, i mean if emailId is already exists how to show the user that email already exists plz try some other Id’s

    Any suggestions are helpful

    • Instead of using an ‘upsert’ you can do an ‘insert’ which will cause an error if the id already exists. Or you can first do a ‘get’ and see if the response comes back with a result. All interactions with Couchbase are very fast.