Ricardo Brandao
Ricardo Brandao

Reputation: 141

Access CouchDB from another PC

I've just installed CouchDB on my Windows Machine and worked well.

Now, I'd like to access from another machine in the same network.

I've changed on local.ini the bind_address from 127.0.0.1 to 0.0.0.0:

[chttpd]
bind_address = 0.0.0.0
port = 5984

I restarted the Apache CouchDB service, but it doesn't work. When I try to access from another computer, for instance using curl -X GET http://192.168.25.49:5984, I don't get any response.

When I run the same command in the local machine (where CouchDB is running) I get:

curl -X GET http://192.168.25.49:5984
{"couchdb":"Welcome","version":"2.1.1","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

My expectation was I get the same result running from another machine in the same network.

Upvotes: 0

Views: 2322

Answers (2)

Nikhil Sinha
Nikhil Sinha

Reputation: 951

In my case, allowing port 5984 through Windows Firewall wasn't enough. I'm using Apache CouchDB 2.3.1 on a Windows 10 machine. I had to implement the following steps:

  1. Changed bind_address from 127.0.0.1 to 0.0.0.0 in both the [chttpd] and [httpd] sections of CouchDB/etc/local.ini. Stop and start CouchDB after this step.
  2. Created an Inbound Rule in Windows Firewall to allow port 5984 exactly as @Ricardo has mentioned in his answer. I still couldn't access CouchDB from another machine in the same network.
  3. After a lot of searching, implemented what has been mentioned in this answer and realised that the request from the remote machine is trying to access a program called erl.exe. enter image description here
  4. Then I went to check whether erl.exe is allowed by Windows Firewall. So I browsed to Control Panel > System and Security > Windows Defender Firewall and clicked on Allow an app or feature through Windows Defender Firewall in the left menu. And voila! erl wasn't checked. I checked the tick to the left of erl and also ensured that both the Private and Public checkboxes were checked for erl. enter image description here

Once I did the above, I was able to access CouchDB from another machine in the same network.

Upvotes: 2

Ricardo Brandao
Ricardo Brandao

Reputation: 141

With thanks to @Flimzy, the problem was there is not a rule in the Windows Firewall.

I've just created a rule to allow external access, following the instructions on this link:

Control Panel > Windows Firewall
Advanced Settings
Inbound Rules > New rule
Port > next select "TCP" and enter "5984" as the local port.
Click next, and allow the connection.
Click next again, and ensure that "Domain", "Private" and "Public" are all ticked.
Name your firewall rule, then save it.

After that, I got access the CouchDb from another machine and got the desired answer:

curl -X GET http://192.168.25.49:5984
{"couchdb":"Welcome","version":"2.1.1","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}}`

Upvotes: 3

Related Questions