Docker - Failed to connect to localhost port 4000: Connection refused
if you are running your docker on Mac and trying to connect to your dependancies (postgres etc) using localhost, replace localhost with docker.for.mac.localhost
I'm not very familiar with docker, but it sounds like your setup is such that your docker instance is running in a virtual machine, and you're trying to access an application bound to localhost (the vm) from your Windows machine. The reason you would get a refusal here from curl is because nothing is actually listening on port 4000 on the host (Windows).
Try to find the IP that your docker instance is using by:
$ docker-machine ip default
Now that you know the IP address, try curl again. You can even have it evaluated within the command like so:
$ curl http://$(docker-machine ip default):4000