Install an Apache CouchDB Database Server on Ubuntu 20.04

Updated on May 9, 2022
Install an Apache CouchDB Database Server on Ubuntu 20.04 header image


Apache CouchDB is an open-source NoSQL database server designed to store data as JSON documents. CouchDB accepts JavaScript MapReduce syntax and HTTP API as the primary query languages to process data.

Developed in Erlang, CouchDB implements real-time scalability and replication features for highly-available distributed database systems to sync data in low bandwidth network connections. Such features make CouchDB a good choice for developing fault-tolerant banking, telephony, e-commerce, and instant messaging applications.

This guide walks you through installing and implementing the CouchDB database server on Ubuntu 20.04.


To proceed with this guide, you require:

1. Install Dependencies and Download the CouchDB Package

The Apache CouchDB package is not available in the official Ubuntu repository. Follow the steps below to add a third-party software repository to your system.

  1. SSH to your server as a non-root sudo user.

  2. Update the package information index.

     $ sudo apt update 
  3. Install curl, apt-transport-https, and gnupg dependency packages.

     $ sudo apt install -y curl apt-transport-https gnupg
  4. Download the CouchDB gpg package key. The apt tool requires it to trust a third-party repository.

     $ curl | gpg --dearmor | sudo tee /usr/share/keyrings/couchdb-archive-keyring.gpg >/dev/null 2>&1 source /etc/os-release
  5. Add the CouchDB repository to the list of available and downloadable packages.

     $ echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] focal main" | sudo tee /etc/apt/sources.list.d/couchdb.list >/dev/null
  6. Update the package information index to refresh the new repository entry.

     $ sudo apt update
  7. Install the couchdb package.

     $ sudo apt install -y couchdb
  8. Press Tab and then Enter to proceed with the installation.

  9. Select standalone configuration in the next step. Then, press Tab followed by Enter to proceed.

     General type of CouchDB configuration:   
  10. Leave the value of the bind-address as and press Tab and then Enter to continue.

      CouchDB interface bind address:            

  11. Type in your preferred administrator password and press Tab followed by Enter to proceed.

     Password for the CouchDB "admin" user:  
  12. Repeat the administrator password and press Tab then Enter to continue.

     Repeat password for the CouchDB "admin" user: 
  13. You've now completed the CouchDB installation. Manage the couchdb package using the following commands.

    • Start the couchdb service.

        $ sudo systemctl start couchdb
    • Stop the couchdb service.

        $ sudo systemctl stop couchdb
    • Enable the couchdb service to start at boot.

        $ sudo systemctl enable couchdb
    • Restart the couchdb service.

        $ sudo systemctl restart couchdb

2. Create and Use a CouchDB Database

You can execute queries on the CouchDB database server using two methods.

  1. The CouchDB HTTP API. CouchDB ships with a JSON REST API that allows you to interact with the database server by sending requests via the HTTP protocol.

  2. The CouchDB Fauxton interface. This web-based software provides an intuitive interface for managing your CouchDB on a web browser.

2.1. CouchDB HTTP API

You can interact with the CouchDB API using different HTTP clients. This guide uses the Linux curl command to perform basic database operations.

  1. Execute the command below to return basic information about the installed CouchDB server. Replace EXAMPLE_PASSWORD with the correct password for the administrator account.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@

    You should receive the following output.

           "name":"The Apache Software Foundation"
  2. Create a new demo database.

     $ curl -X PUT http://admin:EXAMPLE_PASSWORD@


  3. List the available databases.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@


  4. Create three documents in the demo database. Define each document's data in JSON format and specify a unique ID in the URL using the format ../demo/"1"..., ../demo/"2"..., and ../demo/"3"....

     $ curl -H 'Content-Type: application/json' -X PUT http://admin:EXAMPLE_PASSWORD@"1" -d '{"product_name":"LED BULB" , "retail_price" : 23.55}'   
     $ curl -H 'Content-Type: application/json' -X PUT http://admin:EXAMPLE_PASSWORD@"2" -d '{"product_name":"WIRELESS MOUSE" , "retail_price" : 45.20}'   
     $ curl -H 'Content-Type: application/json' -X PUT http://admin:EXAMPLE_PASSWORD@"3" -d '{"product_name":"4G ROUTER" , "retail_price" : 89.50}'   


  5. List all documents from the demo database.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@


                 "product_name":"LED BULB",
                 "product_name":"WIRELESS MOUSE",
                 "product_name":"4G ROUTER",
  6. Get the details of a single document by specifying its unique ID in the URL. For instance, .../demo/1, .../demo/2, or .../demo/3.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@
     {"_id":"1","_rev":"1-b626670af2e7ee1ae13ffba7ffe83819","product_name":"LED BULB","retail_price":23.55}
  7. Update a document by specifying its unique ID in the URL (/demo/1/) and defining the last _rev (1-b626670af2e7ee1ae13ffba7ffe83819) ID in the JSON body.

     $ curl -H 'Content-Type: application/json' -X PUT http://admin:EXAMPLE_PASSWORD@ -d '{"product_name":"15 WATTS LED BULB" , "retail_price" : 40.89, "_rev":"1-b626670af2e7ee1ae13ffba7ffe83819"}'   

    CouchDB updates the document and assigns a new revision ID as shown below.


    List the document one more time to check the new changes.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@

    The product details are now updated.

     {"_id":"1","_rev":"2-387ee2644327cda7a202ed3ad1a9cad0","product_name":"15 WATTS LED BULB","retail_price":40.89}

    CouchDB doesn't support partial updates to existing documents. However, the update command creates a new document version using the supplied data. Therefore, you can't append new fields to an existing document.

  8. Deleting a document. You must specify the document's unique ID and the revision ID in the query URL to delete it from a database.

    Retrieve the revision ID using the command below for the product with a unique ID of 3.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@


     {"_id":"3","_rev":"1-1ebf435bdc37cf3c5dd32aebdd377d46","product_name":"4G ROUTER","retail_price":89.5}

    Specify the document ID (3) and the revision ID (1-1ebf435bdc37cf3c5dd32aebdd377d46) in the command below to delete the product.

     $ curl -X DELETE http://admin:EXAMPLE_PASSWORD@



    Try retrieving the document one more time.

     $ curl -X GET http://admin:EXAMPLE_PASSWORD@

    You should now get the error below.


2.2. CouchDB Fauxton Interface

Administering the CouchDB server via the Fauxton interface requires some configuration changes. Follow the steps below to edit the default CouchDB settings.

  1. Open the /opt/couchdb/etc/local.ini file in an editor.

     $ sudo nano /opt/couchdb/etc/local.ini
  2. Locate the ;bind_address = entry.

     ;port = 5984
     ;bind_address =
  3. Remove the leading ; character to uncomment the bind_address setting and change its value from to This setting allows CouchDB to listen to all network interfaces.

     ;port = 5984
     bind_address =
  4. Restart the CouchDB server to apply the new changes.

     $ sudo systemctl restart couchdb
  5. Visit the URL below on a web browser and replace with the public IP address of your server.

    The Fauxton login screen appears as shown below.

    CouchDB Log in screen

  6. Log in to the web interface by entering the username (admin) and your password (For instance, EXAMPLE_PASSWORD). Click Log In to proceed. The Fauxton software should now navigate you to the following dashboard screen.

    CouchDB dashboard

  7. Use the Fauxton web interface to perform basic database administration tasks such as creating, retrieving, updating, and deleting databases and documents.


This guide is a walk-through for installing and implementing Apache CouchDB on the Ubuntu 20.04 server. To learn more about CouchDB features, visit the official Apache CouchDB website.