Couchdb: Can't create user. Server responds with 500 Internal Server Error.

Created on 5 May 2020  路  5Comments  路  Source: apache/couchdb

Description

Hello, was following security introduction and got into the error when trying to add a new user to $HOST/_users. The response from curl request and through Fauxton is identical.

Steps to Reproduce

Through curl:

curl -X PUT http://localhost:5984/_users/org.couchdb.user:jan \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'

Response:

*   Trying ::1:5984...
* TCP_NODELAY set
* connect to ::1 port 5984 failed: Connection refused
*   Trying 127.0.0.1:5984...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5984 (#0)
> PUT /_users/org.couchdb.user:jan HTTP/1.1
> Host: localhost:5984
> User-Agent: curl/7.68.0
> Accept: application/json
> Content-Type: application/json
> Content-Length: 69
> 
* upload completely sent off: 69 out of 69 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Cache-Control: must-revalidate
< Content-Length: 47
< Content-Type: application/json
< Date: Tue, 05 May 2020 03:17:23 GMT
< Server: CouchDB/2.3.1 (Erlang OTP/22)
< X-Couch-Request-ID: 913ae46a1b
< X-CouchDB-Body-Time: 0
< 
{"error":"unknown_error","reason":"undefined"}
* Connection #0 to host localhost left intact

And how it looks in Fauxton:

Expected Behaviour

Server shoud respond with something like this:

PUT /_users/org.couchdb.user:jan HTTP/1.1
Accept: application/json
Content-Length: 62
Content-Type: application/json
Host: localhost:5984
User-Agent: curl/7.31.0

Your Environment

  • CouchDB version used: 2.3.1-3 (from Arch community repository)
  • Browser name and version: Chromium Version 80.0.3987.87 (Official Build) Arch Linux (64-bit)
  • Operating system and version: Arch Linux (64-bit) / Kernel: Linux 5.5.2-arch1-1
not a bug

All 5 comments

Can you share your logfile output from when the error occurred? I'm not sure where Arch places it, but in our packages it's usually in /var/log/couchdb or similar.

I also note that CouchDB 2.3.1 doesn't officially support Erlang 22, but perhaps the Arch community has provided their own downstream patches for compatibility...

Here's the output, I start couchdb.service manually

May 05 10:21:23 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:23.960819Z [email protected] <0.295.0> -------- rexi_buffer : cluster stable
May 05 10:21:23 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:23.959978Z [email protected] <0.291.0> -------- rexi_server : cluster stable
May 05 10:21:23 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:23.576165Z [email protected] <0.683.0> 5b095c6b37 localhost:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user:jan 500 ok 5091
May 05 10:21:23 dellpc couchdb[2716]: [error] 2020-05-05T04:21:23.561202Z [email protected] <0.741.0> -------- rexi_server: from: [email protected](<0.738.0>) mfa: fabric_rpc:update_docs/3 exit:{timeout,{gen_server,call,[couch_proc_manager,{get_proc,{doc,<<"_design/_auth">>,{1,[<<>
May 05 10:21:18 dellpc couchdb[2716]: [error] 2020-05-05T04:21:18.579995Z [email protected] <0.755.0> -------- OS Process Error <0.756.0> :: {os_process_error,{exit_status,127}}
May 05 10:21:18 dellpc couchdb[2773]: ./bin/couchjs: error while loading shared libraries: libffi.so.7: cannot open shared object file: No such file or directory
May 05 10:21:14 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:14.069774Z [email protected] <0.421.0> -------- Started replicator db changes listener <0.556.0>
May 05 10:21:14 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:14.061034Z [email protected] <0.376.0> -------- couch_replicator_clustering : cluster stable
May 05 10:21:09 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:09.099178Z [email protected] <0.110.0> -------- config: [features] scheduler set to true for reason nil
May 05 10:21:08 dellpc couchdb[2716]: [error] 2020-05-05T04:21:08.972105Z [email protected] <0.275.0> -------- Could not get design docs for <<"shards/e0000000-ffffffff/_users.1588035186">> error:{badarg,[{ets,member,[mem3_openers,<<"_users">>],[]},{mem3_shards,maybe_spawn_shard_w>
May 05 10:21:08 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:08.966628Z [email protected] <0.295.0> -------- rexi_buffer : started servers
May 05 10:21:08 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:08.959394Z [email protected] <0.291.0> -------- rexi_server : started servers
May 05 10:21:08 dellpc couchdb[2716]: [info] 2020-05-05T04:21:08.937344Z [email protected] <0.227.0> -------- Apache CouchDB has started on http://127.0.0.1:5986/
May 05 10:21:08 dellpc couchdb[2716]: [info] 2020-05-05T04:21:08.937070Z [email protected] <0.227.0> -------- Apache CouchDB has started. Time to relax.
May 05 10:21:08 dellpc couchdb[2716]: [notice] 2020-05-05T04:21:08.815137Z [email protected] <0.110.0> -------- config: [features] pluggable-storage-engines set to true for reason nil
May 05 10:21:08 dellpc couchdb[2716]: [info] 2020-05-05T04:21:08.802713Z [email protected] <0.228.0> -------- Starting couch_sup
May 05 10:21:08 dellpc couchdb[2716]: [info] 2020-05-05T04:21:08.800442Z [email protected] <0.227.0> -------- Apache CouchDB 2.3.1 is starting.

The error is:

May 05 10:21:18 dellpc couchdb[2773]: ./bin/couchjs: error while loading shared libraries: libffi.so.7: cannot open shared object file: No such file or directory

Your libffi is missing, or incompatible. Please speak to your distribution about fixing the CouchDB binary there.

This is not a CouchDB bug.

Thank you @wohali Just installed libffi dependency and it solved the issue.

Was this page helpful?
0 / 5 - 0 ratings