# Connecting web client to hivemq docker on localhost fails

**URL:** <https://community.hivemq.com/t/connecting-web-client-to-hivemq-docker-on-localhost-fails/2431>\
**Category:** Uncategorized\
**Created:** [October 14, 2023, 12:57pm UTC](https://community.hivemq.com/t/connecting-web-client-to-hivemq-docker-on-localhost-fails/2431 "2023-10-14T12:57:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ounger](https://avatars.discourse-cdn.com/v4/letter/o/5e9695/32.png) [@ounger](https://community.hivemq.com/u/ounger)\
**Post date:** [October 14, 2023, 12:57pm UTC](https://community.hivemq.com/t/connecting-web-client-to-hivemq-docker-on-localhost-fails/2431/1 "2023-10-14T12:57:50Z")

</div>

I’m trying to connect my angular web client using mqtt.js to my **local running hivemq-ce broker** in docker but it fails:

```auto
const url: string = "ws://localhost:8000";
    const options: IClientOptions = {
      clientId: 'myclient',
      username: 'myuser',
      password: '',
      path: "/mqtt"
    };

```

Docker running:

```auto
Extension "Allow All Extension" version 1.0.0 started successfully.
Starting TCP listener on address 0.0.0.0 and port 1883
Starting Websocket listener on address 0.0.0.0 and port 8000
Started TCP Listener on address 0.0.0.0 and on port 1883.
Started Websocket Listener on address 0.0.0.0 and on port 8000.
Started HiveMQ in 2559ms

```

Connecting to the **public hivemq broker** with the following settings works:

```auto
const url: string = "ws://broker.hivemq.com:8000";
const options: IClientOptions = {
  clientId: 'myclient',
  username: 'myuser',
  password: '',
  path: "/mqtt"
};
this.client = mqtt.connect(url, options);

```

Also connecting backend (java/spring) clients to the **local running hivemq-ce broker** works.  
So why cant the web client connect to the local broker?

---

<div class="post-metadata">

**Author:** ![ounger](https://avatars.discourse-cdn.com/v4/letter/o/5e9695/32.png) [@ounger](https://community.hivemq.com/u/ounger)\
**Post date:** [October 14, 2023, 6:07pm UTC](https://community.hivemq.com/t/connecting-web-client-to-hivemq-docker-on-localhost-fails/2431/2 "2023-10-14T18:07:28Z")

</div>

Solved the issue by starting docker with the following command that binds the necessary port 8000:  
docker run --name hivemq-ce -d -p 1883:1883 -p 8000:8000 hivemq/hivemq-ce
