Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 926
Karthik Avatar asked Jul 26 '13 20:07

Karthik


2 Answers

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.

like image 145
Rajat Beck Avatar answered Sep 21 '22 16:09

Rajat Beck


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.

like image 33
Michael Dunham Avatar answered Sep 23 '22 16:09

Michael Dunham