Last Updated: February 25, 2016
·
8.141K
· leifhanack

Failed connect to localhost:5984; Connection refused

I tried to run a CouchDB inside boot2docker on OSX.

docker run -d -p 5984:5984 --name couchdb tutum/couchdb

The container was running but nevertheless I couldn't connect to http://localhost:5984/.
Mmh? docker logs <containerId> showed alternating logs telling me that the DB is started or starting. Weird, time to find out what's up:

boot2docker ssh
cd /
find . -name "couch.log"
less ./mnt/sda1/var/.../usr/local/var/log/couchdb/couch.log

Ok, the DB was up and running. Double checked it with curl http://0.0.0.0:5984/ and started to search. It found an docker issue describing a solution:

VBoxManage controlvm boot2docker-vm natpf1 "couchdb,tcp,,5984,,5984"

This line will forward the port from the VBox to my machine. Worked!

A more generic solution

I found out that boot2docker will be replaced with boot2docker-cli. If you initialize a new virtual machine with this tool, it will add a host only interface, via which you will be able to access a Docker container's ports with no extra configuration.

2 Responses
Add your response

hmmm thats all totally WRONG at all i am coding at docker you can reach us @ freenode irc #docker

you simply use your boot2docker instance and build a bridged network then it would work totally simply read about bridged networking in vbox.

you should invest in that step becaus in production you will face the same situation and there you can't Port Forward via Nat without Exposing your Whole Box to each one that whants to use it ;)

Greetings from berlin

over 1 year ago ·

Glad that you re-read your original comment and bring some value in:)

Nevertheless, how can it be TOTALLY WRONG if it works. If you have a better alternative, I'm fine. Your suggested solution is right AND already part of boot2docker 0.8 as I wrote. They call it host only interface.

If you need some more background:

a open docker issue similar to the one I had

host only interface request for boot2docker

the same request for boot2docker-cli

the merge

the release

Regards, Leif

over 1 year ago ·