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

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


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 = 5984bind_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.


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 0curl: (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.


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.