5

I am a beginner to CouchDB and want to work on a project using CouchDB. I have set up the server in my laptop (running Ubuntu 13.04) by following the instructions given in Beginning CouchDB handbook but with little change in the version of CouchDB (explaination in the handbook had older version). I downloaded the latest Source version of the CouchDB and performed the rest actions that was told in that book using Terminal. I am able to successfully start the server from Terminal but when I use

$ curl http://127.0.0.1:5984/

I am getting this

curl: (7) Failed connect to 127.0.0.1:5984; Connection refused

as output instead of this

{"couchdb" : "Welcome", "version" : "1.3.1",}

I configured the server in the following way:

I first downloaded the Source file from the official website, extracted the same and copied it to my /home directory and then performed the following actions in Terminal

$ cd apache-couchdb-1.3.1/

$ ./configure

$ make

$ sudo make install

$ sudo mkdir -p /usr/local/var/lib/couchdb

$ sudo mkdir -p /usr/local/var/log/couchdb

$ sudo mkdir -p /usr/local/var/run

$ sudo chown -R couchdb /usr/local/var/lib/couchdb

$ sudo chown -R couchdb /usr/local/var/log/couchdb

$ sudo chown -R couchdb /usr/local/var/run

$ sudo cp /usr/local/etc/init.d/couchdb /etc/init.d

$ sudo update-rc.d couchdb defaults

Starting and viewing the working server

$ sudo /etc/init.d/couchdb start

$ curl http://127.0.0.1:5984

When I enter this command to start a server sudo /etc/init.d/couchdb start I get a reply in Terminal like this:

* Starting database server couchdb                                      [ OK ]

I even tried turning off the system's firewall but then the results are same. If any of you have experienced the same, please share your experience in solving this issue or let me know any alternative way of configuring the same.

Thank you

1
  • 1
    Hi. Have you found an answer/solution to this? And do you still remember it? :) You could post it and accept your answer, so other people could find it.
    – Seer
    May 21, 2015 at 7:24

6 Answers 6

7

You need to uncomment port and bind_address in the local.ini file in /etc/couchdb/local.ini

For Ubuntu 20:- /opt/couchdb/etc/local.ini

change:

;port = 5984
;bind_address = 127.0.0.1

to:

port = 5984
bind_address = 0.0.0.0

and then restart CouchDB

curl -X POST http://admin:password@localhost:5984/_restart -H"Content-Type: application/json"

and you are good to go.

1
  • I did those steps but still, I am getting --> curl: (7) Failed to connect to localhost port 5984: Connection refused Jun 28, 2021 at 9:36
4

I was having the same issue and I ran a "curl -v localhost:5984" and got the following output on my Mac:

curl -v localhost:5948
* Rebuilt URL to: localhost:5948/
* Hostname was NOT found in DNS cache
*   Trying ::1...
* connect to ::1 port 5948 failed: Connection refused
*   Trying fe80::1...
* connect to fe80::1 port 5948 failed: Connection refused
* Failed to connect to localhost port 5948: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 5948: Connection refused

For some reason "curl" couldn't resolve the name "localhost" and failed back to an IPV6 version of localhost which couchdb wasn't listening for.

When I changed the request to "curl 127.0.0.1:5984" the request worked and came back with:

curl 127.0.0.1:5984
{"couchdb":"Welcome","uuid":"7483189ec0bfb8df387a055674ea05f2","version":"1.6.1","vendor":{"version":"1.6.1-1","name":"Homebrew"}}

You may be having a similar problem, but even if you aren't, adding the "-v" option to your "curl" command might help you troubleshoot it.

1
  • Thanks. That sorted me.
    – Gareth
    Jul 31, 2015 at 18:07
3

Just a note to others using a Mac, CouchDB does not like it if you rename your user directory, which I had to do recently and everything Couch broke hard.

To fix it, you need to first find (~/Library/Application Support/CouchDB2/etc/couchdb/local.ini) and edit your local.ini file to replace all the hard-coded absolute paths with the new user directory, then you need to recreate the ~/Library/Preferences/couchdb2-local.ini symbolic link to point to that file again.

2

i got the same error after installing from "https://linuxize.com/post/how-to-install-couchdb-on-ubuntu-20-04/"

you just have to run

sudo /etc/init.d/couchdb start

1

It could be that you're hitting the open file limit in Ubuntu (1024 by default) and so TCP connections cannot be created. I'm far from an expert on Ubuntu but this has been reported as a previous cause of such errors. See askubuntu.com for instructions on how to increase this limit. There is also a Resource Limits section in the CouchDB Wiki which might helpful.

0

The DNS looks for the right IP address from the files /etc/resolv.conf and /etc/hosts

You need to remove the localhost IP address from /etc/hosts file, where DNS will try to resolve from 127.0.0.1 which is unknown to external world.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.