Sunday, 10 August 2014

Installing CouchDB 1.6.0 on the Raspberry Pi

Update 03.11.2015

The Erlang Solutions Repository now contains a new version of Erlang. The major version is now 18. This is too high for the couch in version 1.6.x.
For this reason, please omit the step of including the Erlang Solutions Repository.
Just rely on what you get from the default Raspbina/Debian repos.
I still have to verify this with Wheezy, but for the new Raspbian Jessie image this does the trick.

Also please note that the couch is now available in version 1.6.1.
The instructions below are valid for this version too, as described here.

Building CouchDB 1.6.0 On Your Pi

CouchDB 1.6.0 has been released and of course we want to have it running on our Pis.
I guess my previous blog on installing version 1.5.1 is still valid but couchDB 1.6.0 is now able to run on Erlang 1.17 and that makes for a sight difference during installation.

Preparing the Pi

Nothing new here...
  • I used a brand new 16 GB card.
  • Download the latest Raspbian Wheezy from
    At the time of this writing, the image version was 2014-06-20
  • Install the image on your Pi and do the regular raspi-config
    • Extend the partition
    • Set your locales
    • ...
    • Btw, I did not change the default memory split nor did I overclock
  • Re-boot the Pi for the partition extension to take effect
  • update and upgrade your installation
The Pi is now ready.

Add Erlang Solutions' Repository (omit this step, see update 03.11.2015 hint)

Again, we will not add the Cloudant repository for Spidermonkey, but this time add the Erlang Solutions repository in order to install their Erlang package. This will get you an Erlang 1.17 version which is now ok for couchDB 1.6.0.
The following instructions have been taken from Erlang Solutions' download section:
# Add the following line to your /etc/apt/sources.list:
deb wheezy contrib

#Next, add the Erlang Solutions public key for apt-secure using following commans:
sudo apt-key add erlang_solutions.asc

# update repository cache
sudo apt-get update

Install what's needed

Install the following packages:
# Install Compilers
sudo apt-get install erlang-nox
sudo apt-get install erlang-dev
# Spidermonkey JS engine as lib
sudo apt-get install libmozjs185-1.0
# Development headers for spidermonkey lib
sudo apt-get install libmozjs185-dev
# Dev files for libcurl (openSSL)
sudo apt-get install libcurl4-openssl-dev
# Dev files for icu (Unicode and Locales)
sudo apt-get install libicu-dev

Create an account for couchDB

Next we have to create an account for couchDB:
# Create couchDB account
sudo useradd -d /var/lib/couchdb couchdb

sudo mkdir -p /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb /var/lib/couchdb

sudo chown -R couchdb:couchdb /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb

sudo chmod -R g+rw /usr/local/{lib,etc}/couchdb /usr/local/var/{lib,log,run}/couchdb
The next step is downloading the source code and unpacking it:
(find an appropriate mirror near you)
# Download source and unpack
tar xzf apache-couchdb-*.tar.gz
In order to start the "configure" and "make" process, switch into the couchDB directory:
# Change into the couchDB directory
cd apache-couchdb-1.6.0
Now configure the build:
#Configure the build
./configure --prefix=/usr/local --with-js-lib=/usr/lib --with-js-include=/usr/include/js --enable-init
When configure is through, you should see this message:
“You have configured Apache CouchDB, time to relax.
Run 'make && sudo make install' to install.”
This also tells you what the next step will be: running make and make install.
# running make and make install
make && sudo make install
This will take a couple of minutes. But when its done, you have couchDB 1.6.0 compiled on your pi.

Finally create some soft links, make the service start up at boot-time and start couchDB:
# Start couchDB
sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb
sudo /etc/init.d/couchdb start
sudo update-rc.d couchdb defaults
# see if its running...

As you can see, the couchDB service binds to localhost.
If you want to reach couchDB from another machine, maybe from another Pi :-), change this.
Open local.ini, find the [httpd] section, activate the binding_address and set it to the IP of your Pi:
# make couchDB accessible within your network
sudo vi /usr/local/etc/couchdb/local.ini
Within this file, find the [httpd] section, activate bind_address and set it to
It should now look like this:

;port = 5984
bind_address =

As a final test, re-boot your Pi and try to reach couchDB Futon:

And that's it. CouchDB 1.6.0 is running on your Pi.

There is one additional step suggested by a kind reader:
# Now including this hint sent by anonymous
# make couchdb user (created above) owner of local ini-file
sudo chown couchdb:couchdb /usr/local/etc/couchdb/local.ini


The instructions above are based on an installation guide compiled by Dave Cottlehuber on the new couchDB Confluence Wiki. It describes the process of installing couchDB on a Debian system.
The Wiki entry is here.
I slightly adjusted this process to be working for the Pi too and now with the Erlang Solutions repository included, this guide is even closer to the Wiki than the one for version 1.5.1.


  1. Thanks!
    "sudo vi /usr/local/etc/couchdb/local.ini."
    The last do is too much.

  2. This comment has been removed by the author.

  3. why does my terminal not accept the following command?

    pi@pi01 ~ $ sudo /etc/init.d/couchdb start

    sudo: /etc/init.d/couchdb: command not found

    any ideas?

  4. Hi Marc...out of the box, I'm afraid I have no idea. Did you follow the softlink and checked if couchdb is really there? Did you try to start couchdb from its original directory?

  5. I too got the command not found error. However, couchdb does exist in the bin folder inside the original directory. I can't seem to run it from there, should i just copy it to /etc/init.d ?

    1. Hi Greg,
      I'm a little bit worried now.
      I've configured all my pi's this way without ever facing an issue. But that's quite a while ago now.
      On next occasion I will verify the process.
      Are you using the original Pi or the new mode Pi2B?

    2. I'm using the original Pi with a fresh install of the most recent version of Raspbian (installed through NOOBS).

      I was able to get CouchDB running from the original downloaded location, it won't run automatically but I can manually start it up.

    3. Hi Greg,
      last weekend I was busy getting the couch running on a Pi on Archlinux, so I did not manage to reproduce your problem.
      But if couchdb is missing in /etc/init.d, then earlier on there must have been some problem with creating the soft link. Can you trace back to where the problems started, e.g. is couchdb present in /usr/local/etc/init.d/ ?

  6. Was playing around with Archlinux lately. For the Pi, the Archlinux ARM project is relevant.
    It's a little bit more of an effort to install it on the Pi, but once you have it, you should be able to install the couch from their repo. It's version 1.6.1-4 which sounds cool.
    Guess I'll try this path next...

  7. Hi Volker,

    I tried to follow your instructions on a Pi B Rev2, but I get the following error when configuring the build:

    checking Erlang version compatibility... detected Erlang version: 7.1.0...configure: error: The installed Erlang version must be >= R14B (erts-5.8.1) and =< 17 (erts-6.0) major_version does not match

    I have very little experience with the Pi. Is there a way to solve this?



    1. Hi Rodrigo,
      from the message I figure that your erlang version is too new for couch 1.6.0.
      Try to install couch 1.6.1. This should work.
      If not, than you have to install an older erlang version.
      Hope this helps.
      I'm going to check repositories and versions tonight. Maybe I can give you another hint tomorrow.

    2. Hi Rodrigo,
      I just checked my couch 1.6.1 installation for the installed erlang-nox package: version is 1:17.5.3.
      Please install version 1.6.1 of couchdb and you should be fine.

    3. Hi,
      I just downloaded CouchDB 6.1.1 instead of 6.1.0 and still got the same error with Erlang compatibility.
      How can I install older Erlang version that can work with CouchDB?


  8. Hi,
    I just downloaded CouchDB 6.1.1 instead of 6.1.0 and still got the same error with Erlang compatibility.
    How can I install older Erlang version that can work with CouchDB?


    1. Hi,
      can you please run this:
      sudo apt-cache policy erlang-nox
      and post the result?

    2. Here you go;

      ~ $ sudo apt-cache policy erlang-nox
      Installed: 1:18.1
      Candidate: 1:18.1
      Version table:
      *** 1:18.1 0
      500 wheezy/contrib armhf Packages
      100 /var/lib/dpkg/status
      1:17.5.3 0
      500 wheezy/contrib armhf Packages
      1:17.5 0
      500 wheezy/contrib armhf Packages
      1:17.4 0
      500 wheezy/contrib armhf Packages
      1:17.3.2 0
      500 wheezy/contrib armhf Packages
      1:17.3 0
      500 wheezy/contrib armhf Packages
      1:17.1 0
      500 wheezy/contrib armhf Packages
      1:16.b.3-3 0
      500 wheezy/contrib armhf Packages
      1:16.b.3 0
      500 wheezy/contrib armhf Packages
      1:16.b.2 0
      500 wheezy/contrib armhf Packages
      1:16.b 0
      500 wheezy/contrib armhf Packages
      1:15.b.1-dfsg-4+deb7u1 0
      500 wheezy/main armhf Packages

    3. ok, seems like Erlang Solutions Repository now contains a new major version 1:18.1.
      This means that my tutorial does no longer work correctly. Sorry.
      What you can do is to leave out the first step: including the Erlang Solutions Repo.
      You will then fall back to using the version in the regular raspbian repository. I tried this today with the brand new Jessie based raspbian and it worked well.
      Hope this helps.
      I will update the tutorial as soon as possible.
      Thanks for the hint and sorry for your trouble.

  9. This comment has been removed by the author.

  10. I just wanted to say thank you.
    I have just seamlessly installed CouchDB 1.6.1 on Raspbian Jessie on a Pi 2.
    All sorted in the time it took to heat up a bowl of soup.
    I'm very grateful for your well written, easy to follow instructions.

    1. Thank you very much for your kind feedback.
      You made my day :-)

  11. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Couch DB, kindly contact us
    MaxMunus Offer World Class Virtual Instructor led training on Couch DB. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Nitesh Kumar
    Skype id: nitesh_maxmunus
    Ph:(+91) 8553912023