# Local ( docker to Local solace connection failure.

**URL:** <https://community.solace.com/t/local-docker-to-local-solace-connection-failure/924>\
**Category:** General Discussions\
**Created:** [September 7, 2021, 3:29am UTC](https://community.solace.com/t/local-docker-to-local-solace-connection-failure/924 "2021-09-07T03:29:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![balajirengarajan](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@balajirengarajan](https://community.solace.com/u/balajirengarajan)\
**Post date:** [September 7, 2021, 3:29am UTC](https://community.solace.com/t/local-docker-to-local-solace-connection-failure/924/1 "2021-09-07T03:29:49Z")

</div>

Kindly help. @marc@JamilAhmed @Neha

I am getting the connection failure error when i tried to connect  
from Local Docker ( simple application Spring cloud - Function Processor) to solace Localhost.

I checked the /etc/hosts in my Mac and see that it is correctly mapped for localhost.

Please note that before deploying to docker, same application works fine in my eclipse as spring boot app.

Error details:

021-09-07 03:20:56.969 INFO 1 — [main] c.s.j.protocol.impl.TcpClientChannel : Connection attempt failed to host ‘localhost’ ConnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: e6f94322ff6a/1/#00120001/CBzOqDQrGK Local port: -1 Remote addr: localhost Remote port: 55555) - Error communicating with the router. cause: java.net.ConnectException: Connection refused ((Client name: e6f94322ff6a/1/#00120001/CBzOqDQrGK Local port: -1 Remote addr: localhost Remote port: 55555) - )  
2021-09-07 03:20:59.971 INFO 1 — [main] c.s.j.protocol.impl.TcpClientChannel : Connecting to host ‘orig=localhost, host=localhost’ (host 1 of 1, smfclient 1, attempt 1 of 1, this\_host\_attempt: 13 o

---

<div class="post-metadata">

**Author:** ![arih](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/arih/32/130_2.png) [@arih](https://community.solace.com/u/arih)\
**Post date:** [September 7, 2021, 4:06am UTC](https://community.solace.com/t/local-docker-to-local-solace-connection-failure/924/2 "2021-09-07T04:06:40Z")

</div>

Hi @balajirengarajan

If your app is inside a docker container and your Solace event broker are running locally, then you can’t use localhost to access the broker from within your container. Localhost simply refers to the container itself, not your laptop/host. When the app is running locally via IDE or via command line as Spring boot app, the app is able to access the broker since the broker container should have exposed the ports to your local OS (the -p 55555:55555 in your docker run command).

Now I assume your Solace broker is also deployed as a docker container. I would use the same network for both container so they can access each other simply using their container name. I did exactly that in one of my demo repo here: [GitHub - arih1299/rest-vs-smf-docker: Comparing full REST services and REST + Solace SMF with docker](https://github.com/arih1299/rest-vs-smf-docker)

If you already have your broker container running, you can use docker network connect command to attach it. So, here’s how I’d do it:

First, create the network:  
`docker network create solace-net`

Second, attach my broker container to that network:  
`docker network connect <mysolacecontainername> solace-net`

Third, either use `--network solace-net` when running the app container, or just attach it like we did with the solace broker container.

---

<div class="post-metadata">

**Author:** ![balajirengarajan](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@balajirengarajan](https://community.solace.com/u/balajirengarajan)\
**Post date:** [September 7, 2021, 1:47pm UTC](https://community.solace.com/t/local-docker-to-local-solace-connection-failure/924/3 "2021-09-07T13:47:00Z")

</div>

Thank you @arih for your support.

---

<div class="post-metadata">

**Author:** ![Tamimi](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tamimi/32/2190_2.png) [@Tamimi](https://community.solace.com/u/Tamimi)\
**Post date:** [September 7, 2021, 6:54pm UTC](https://community.solace.com/t/local-docker-to-local-solace-connection-failure/924/4 "2021-09-07T18:54:39Z")

</div>

Hey @balajirengarajan! did this resolve your issue?
