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

I am new to CouchDB and want to work on a project using CouchDB. I set up the server on my laptop (running Ubuntu 13.04) by following the instructions in the Getting Started CouchDB manual, but with a slight change in the version of CouchDB (the explanation in the manual was older). I downloaded the latest version of the original version of CouchDB and followed the rest of the steps in this book using the terminal. I can successfully start the server from the terminal, but when I use

$ curl http://127.0.0.1:5984/ 

I get it

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

as output instead

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

I configured the server as follows:

First, I downloaded the source file from the official site, extracted it and copied it to my / home directory, and then performed the following actions in the 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 a production server

 $ sudo /etc/init.d/couchdb start $ curl http://127.0.0.1:5984 

When I enter this command to start the sudo / etc / init.d / couchdb start server, I get a response in the terminal as follows:

 * Starting database server couchdb [ OK ] 

I even tried to disable the system firewall, but then the results will be the same. If any of you have experienced the same thing, share your experience in solving this problem or let me know an alternative way to configure.

thanks

+4
source share
5 answers

I had the same problem and I ran "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 could not resolve the name localhost and did not return to the local IPV6 host version that couchdb was not listening to.

When I changed the request to "curl 127.0.0.1:5984", the request worked and returned using:

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

You may have a similar problem, but even if you do not, adding the -v option to your curl command may help you fix it.

+2
source

It's just that for other Mac users, CouchDB doesnโ€™t like it if you rename your user directory, which I had to do recently, and all that Couch badly broke.

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

+3
source

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

changes:

 ;port = 5984 ;bind_address = 127.0.0.1 

in

 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.

+2
source

You might be able to hit the open file restriction in Ubuntu (default is 1024) and therefore TCP connections cannot be created. I'm far from an Ubuntu expert, but this was reported as the previous reason for such errors. For more information on how to increase this limit, see askubuntu.com . The CouchDB Wiki also has a Resource Limit section.

+1
source

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

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

0
source

Source: https://habr.com/ru/post/1493760/


All Articles