5

I've installed CouchDB on my vagrant 0.9.0 box that is running CentOS 6.2.

In Vagrantfile I've added config.vm.forward_port 5984, 5985.

After reloading vagrant i attempt to curl the address: curl -v localhost:5985 with poor results.

* About to connect() to localhost port 5985 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5985 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
> Host: localhost:5985
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection #0

I get the feeling that port forwarding isn't working properly - at first I thought it might have something to do with iptables so I disabled that but, alas, results did not improve.

Been beating my head against this for days now. Would greatly appreciate some assistance.

joseym
  • 1,332
  • 4
  • 20
  • 34

2 Answers2

17

It's quite likely that your CouchDB is listening on address 127.0.0.1 of the virtual machine (not of the physical machine). This is the default for CouchDB. Do you have the following in local.ini?

[httpd]
bind_address = 0.0.0.0

After restarting CouchDB check with netstat, on the virtual machine, if the change took effect:

sudo netstat -tlnp |grep :5984

Then check that CouchDB is running fine from the virtual machine:

curl http://127.0.0.1:5984/

If you don't see {"couchdb":"Welcome","version":"1.1.1"}, check the logs for error messages. It may be some permissions problem.

How have you installed CouchDB?

Marcello Nuccio
  • 3,901
  • 2
  • 28
  • 28
  • I modified local.ini in /etc/couchdb/ to uncomment the `bind_address` line and changed it to your recommendation above. Same result when i try to curl from the host machine. "curl: (52) Empty reply from server" – joseym Jan 28 '12 at 17:34
  • @joseym, I've added some more tips. HTH. – Marcello Nuccio Jan 30 '12 at 08:42
  • Thanks @Marcello, I followed your instructions and the change to local.ini took and I was able to curl from the VM. I installed couch via `yum install couchdb` – joseym Jan 30 '12 at 14:06
  • I had to make the bind change in `default.ini` and not `local.ini`, otherwise, this answer worked for me when I was having the same issue, thanks. – Stepan Mazurov Mar 27 '12 at 21:47
  • I just dont understand this - after fighting with this for ages with no forward movement I went to mongodb. I'm starting a new project and would LOVE to use couchdb but I'm hitting this same wall. I have modified both my `default.ini` and `local.ini` to bind to `0.0.0.0` – joseym Mar 29 '12 at 18:57
  • @joseym, I would gladly help if you respond to ALL the questions I've done: what's the output of netstat? what's in the logs? – Marcello Nuccio Mar 30 '12 at 06:42
  • Thanks for this answer - this was helpful for a problem that I was having, not around Mongo, but with another app. The application was binding to 127.0.0.1 and it should have been binding to 0.0.0.0. Correcting this helped me get port forwarding working! – shedd Jan 24 '14 at 18:36
  • In case anyone is experiencing this with rails, run rails server like so `bundle exec rails s -b 0.0.0.0` – Abhijith Nov 15 '14 at 03:13
  • Marcello, updating `local.ini` does the trick for me, thanks (Vagrant, Ubuntu 14.04) – skanatek Dec 23 '14 at 17:58
4

in my case, the solution to a very similar problem was much more obvious: coming from ubuntu, I didn't expect a firewall to be running on the centos box

this will disable it:

sudo service iptables stop

thanks to this blog!

Cpt. Senkfuss
  • 1,347
  • 3
  • 12
  • 20