How to install couchdb

In this article you will learn how to install CouchDB under Linux / UNIX environments.


Note: When this article was published (May 2013) we used Debian based operating system Ubuntu 12.04 LTS. This works under Ubuntu 10.04 LTS, Ubuntu 13, Debian 6 and Debian 7.


What is CouchDB?

CouchDB also is a document database server that provides high performance, high availability, and scalability for web applications. It is similar to other “NoSQL” database servers like Redis, Cassandra and MongoDB.


It has features like embedding which makes reads and writes fast. Indexes can include keys from embedded documents. Arrays and features like high availability help replicate server with automatic master failover.


Couchdb is a non-relational database; it keeps its data in separate JSON document formats. The major advantage of this approach is that there is no need for a particular schema for the information that is inputted.


You either need to run commands as root and ignore sudo in the commands below or if you are logged in with your user it should be a sudo user.


sudo apt-get update

sudo apt-get -y upgrade


The first command updates software update repositories. The second command upgrades software packages installed against the updated repositories.


To install CouchDB use “apt-get” to install from the repositories using the command below:


sudo apt-get install couchdb


CouchDB is listening by default on localhost ; you get query / retrieve its basic data using the “curl” command.

curl localhost:5984

CouchDB by default is listening on port “5984”

If curl is not installed on your host / server you can install using the command below:


sudo apt-get install curl


Once you do above curl command against localhost 5984 you will see an output similar to that listed below; this tells you the version number and confirms you that you have installed CouchDB correctly:




Create a new database with CouchDB

If you want to create a new database for playing around or for your application you can use the command below:


curl -X PUT localhost:5984/my_db

Using the above command you have created a database called “my_db” by sending a PUT command to the CouchDB server.


Output of the curl command will be similar to that message below. This will confirm that the database has been created.




At this stage you have successfully installed CouchDB on our server / machine!


Since CouchDB is listening as localhost (loopback address, if you make it live users will be able to execute commands on your server, which you probably don’t want.


If you want to access CouchDB interface you can do this via SSH tunneling; use the start OpenSSH server and client installed.


At this stage, we assume that you already have the OpenSSH client installed on your host from which you can access the DB.


You can use the command below on the machine from which you would like to access CouchDB server by mapping a local port of your host / machine to the CouchDB server and access.

ssh -L5984: yourusername@couchdb-ipaddress


In our case we did below:


ssh -L5984: shellways@


L= Local port which we want to map the remote port. We can use any port which is currently not being used is the IP (localhost) which we can to map to. After is the port of the CouchDB server.


Now you can access from your webserver by pointing to the below URL

Note, this will keep working unless the SSH connection is terminated between both the hosts.

Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)