# Can not connect to docker instance with exposed port to 127.0.0.1

**URL:** <https://travis-ci.community/t/can-not-connect-to-docker-instance-with-exposed-port-to-127-0-0-1/1991>\
**Category:** Linux\
**Tags:** build-env\
**Created:** [January 24, 2019, 3:27pm UTC](https://travis-ci.community/t/can-not-connect-to-docker-instance-with-exposed-port-to-127-0-0-1/1991 "2019-01-24T15:27:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arturictus](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@arturictus](https://travis-ci.community/u/arturictus)\
**Post date:** [January 24, 2019, 3:27pm UTC](https://travis-ci.community/t/can-not-connect-to-docker-instance-with-exposed-port-to-127-0-0-1/1991/1 "2019-01-24T15:27:34Z")

</div>

Hi,  
I have a gem in ruby that needs to make HTTP requests to a rails application for testing.  
I built a docker image, run it and expose the port but when my tests can not resolve the url.  
$ docker ps -a  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
9a9f4c0cb68f dummy “/bin/sh -c ‘[’/bi…” 1 second ago Up Less than a second 127.0.0.1:9873-\>9873/tcp reverent\_pasteur  
in my tests:  
HTTP::ConnectionError:  
failed to connect: Connection refused - connect(2) for “127.0.0.1” port 9873

I tested in local and I can access to the port.  
This is the job: [https://travis-ci.org/arturictus/wrappi/jobs/483778736](https://travis-ci.org/arturictus/wrappi/jobs/483778736)  
docker file: [https://github.com/arturictus/wrappi/blob/readme/spec/dummy/Dockerfile](https://github.com/arturictus/wrappi/blob/readme/spec/dummy/Dockerfile)  
travis.yml: [https://github.com/arturictus/wrappi/blob/readme/.travis.yml](https://github.com/arturictus/wrappi/blob/readme/.travis.yml)

Thanks
