If your CouchDB doesn’t start after you’ve just installed, check the following things:
## what version of erlang are you running? Ensure it is supported
erl -noshell -eval 'io:put_chars(erlang:system_info(otp_release)).' -s erlang halt
## are the erlang crypto (SSL) libraries working?
erl -noshell -eval 'case application:load(crypto) of ok -> io:put_chars("yay_crypto\n") ; _ -> exit(no_crypto) end.' -s init stop
erl -env ERL_LIBS $ERL_LIBS:/path/to/couchdb/lib -couch_ini -s crypto
%% test SSL support. If this fails, ensure you have the OTP erlang-crypto library installed
crypto:md5_init().
%% test Snappy compression. If this fails, check your CouchDB configure script output or alternatively
%% if your distro comes with erlang-snappy make sure you're using only the CouchDB supplied version
snappy:compress("gogogogogogogogogogogogogogo").
%% test the CouchDB JSON encoder. CouchDB uses different encoders in each release, this one matches
%% what is used in 2.0.x.
jiffy:decode(jiffy:encode(<<"[1,2,3,4,5]">>)).
%% this is how you quit the erlang shell.
q().
Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]
Eshell V6.2 (abort with ^G)
1> crypto:md5_init().
<<1,35,69,103,137,171,205,239,254,220,186,152,118,84,50,
16,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>
2> snappy:compress("gogogogogogogogogogogogogogo").
{ok,<<28,4,103,111,102,2,0>>}
3> jiffy:decode(jiffy:encode(<<"[1,2,3,4,5]">>)).
<<"[1,2,3,4,5]">>
4> q().
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/spidermonkey/lib couchdb
Linux example running as couchdb user:
echo LD_LIBRARY_PATH=/usr/local/lib:/usr/local/spidermonkey/lib couchdb | sudo -u couchdb sh
Failure to start Mochiweb: eaddrinuse
edit your ``etc/default.ini`` or ``etc/local.ini`` file and change the
``[chttpd] port = 5984`` line to an available port.
… OS Process Error … {os_process_error,{exit_status,127}}
then it is likely your SpiderMonkey JavaScript VM installation is not correct. Please recheck your build dependencies and try again.
… OS Process Error … {os_process_error,{exit_status,139}}
this is caused by the fact that SELinux blocks access to certain areas of the filesystem. You must re-configure SELinux, or you can fully disable SELinux using the command:
setenforce 0
Having problems getting CouchDB to run for the first time? Follow this simple procedure and report back to the user mailing list or IRC with the output of each step. Please put the output of these steps into a paste service (such as https://paste.apache.org/) rather than including the output of your entire run in IRC or the mailing list directly.
./configure
make release
cd rel/couchdb
bin/couchdb
strace bin/couchdb 2> strace.out
Are you upgrading from CouchDB 2.0? Install CouchDB into a fresh directory. CouchDB’s directory layout has changed and may be confused by libraries present from previous releases.
Is your CouchDB using a lot of memory (several hundred MB) on startup? This one seems to especially affect Dreamhost installs. It’s really an issue with the Erlang VM pre-allocating data structures when ulimit is very large or unlimited. A detailed dicussion can be found on the erlang-questions list, but the short answer is that you should decrease ulimit -n or define ERL_MAX_PORTS to something reasonable like 1024.
Erlang has a default limit of 1024 ports, where each FD, tcp connection, and linked-in driver uses one port. You seem to have exceeded this. You can change it at runtime using the ERL_MAX_PORTS env variable.
If you see this in the CouchDB error logs, the JavaScript code you are using for either a map or reduce function is referencing an object member that is not defined in at least one document in your database. Consider this document:
{
"_id":"XYZ123",
"_rev":"1BB2BB",
"field":"value"
}
and this map function:
function(doc) {
emit(doc.name, doc.address);
}
This will fail on the above document, as it does not contain a name or address member. Instead, use guarding to make sure the function only accesses members when they exist in a document:
function(doc) {
if(doc.name && doc.address) {
emit(doc.name, doc.address);
}
}
While the above guard will work in most cases, it’s worth bearing JavaScript’s understanding of ‘false’ values in mind. Testing against a property with a value of 0 (zero), '' (empty String), false or null will return false. If this is undesired, a guard of the form if (doc.foo !== undefined) should do the trick.
This error can also be caused if a reduce function does not return a value. For example, this reduce function will cause an error:
function(key, values) {
sum(values);
}
The function needs to return a value:
function(key, values) {
return sum(values);
}
CouchDB 1.1.1 and later contains stricter handling of UTF8 encoding. If you are replicating from older versions to newer versions, then this error may occur during replication.
A number of work-arounds exist; the simplest is to do an in-place upgrade of the relevant CouchDB and then compact prior to replicating.
Alternatively, if the number of documents impacted is small, use filtered replication to exclude only those documents.