# Unable to connect to the device: websocket: bad handshake

**URL:** <https://hub.mender.io/t/unable-to-connect-to-the-device-websocket-bad-handshake/5868>\
**Category:** General Discussions\
**Tags:** port-forwarding\
**Created:** [May 29, 2023, 10:52am UTC](https://hub.mender.io/t/unable-to-connect-to-the-device-websocket-bad-handshake/5868 "2023-05-29T10:52:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![petarkalafatic](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/petarkalafatic/32/1875_2.png) [@petarkalafatic](https://hub.mender.io/u/petarkalafatic)\
**Post date:** [May 29, 2023, 10:52am UTC](https://hub.mender.io/t/unable-to-connect-to-the-device-websocket-bad-handshake/5868/1 "2023-05-29T10:52:12Z")

</div>

hi guys,

I installed the mender-client and mender-connect on the devices I want to connect. Also did the mender client setup for the hosted mender server. Both the devices are listed on the mender server and I see their ID’s.

Downloaded the mender-cli to my computer and did a server login via CLI.  
( question: where can I find the mender-cli file that supports arm architecture?) My computer works fine but the edge device uses arm.

Wanted to test the `mender-cli port-forward` so I connect my computer to the edge device via SSH.  
I used this command:

`mender-cli port-forward <Device ID> 8080:192.168.10.162:8080`  
The IP address being the local IP of the edge device and the Device ID being the ID of the edge device I want to connect.

```auto
Configuration file not found. Continuing.
Connecting to the device <Device ID>.
FAILURE: Unable to connect to the device: websocket: bad handshake

```

Sometimes it’s just this:

`Forwarding from 127.0.0.1:8080 -> 192.168.10.162:8080` and waiting.

Am I doing something wrong here? By reading the docs it should be simple.  
Thank you.

---

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://hub.mender.io/u/johan)\
**Post date:** [June 5, 2023, 6:50am UTC](https://hub.mender.io/t/unable-to-connect-to-the-device-websocket-bad-handshake/5868/2 "2023-06-05T06:50:34Z")

</div>

Could it be the same as  
this: [Mender-connect sometimes fails](https://hub.mender.io/t/mender-connect-sometimes-fails/3399)

---

<div class="post-metadata">

**Author:** ![petarkalafatic](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/petarkalafatic/32/1875_2.png) [@petarkalafatic](https://hub.mender.io/u/petarkalafatic)\
**Post date:** [June 5, 2023, 7:51am UTC](https://hub.mender.io/t/unable-to-connect-to-the-device-websocket-bad-handshake/5868/3 "2023-06-05T07:51:17Z")

</div>

Hello Johan 🙂

I logged in via CLI to the mender server.

Then executed this commands:  
`mender-cli port-forward 3bbe0235-f863-48e9-97e3-dbc1d75fa47g 21000:192.168.8.110:21000`

output:

```auto
Configuration file not found. Continuing.
Connecting to the device 3bbe0235-f863-48e9-97e3-dbc1d75fa47g...
Forwarding from 127.0.0.1:21000 -> 192.168.8.110:21000

```

Then in another terminal tab:  
`ssh mydevice@hosted.mender.io -p 21000`

Output:  
`ssh: connect to host hosted.mender.io port 21000: Connection timed out`

`sudo journalctl -u mender-client -f`

Gives me:

```auto
Jun 05 09:54:11 kafka mender[2711]: time="2023-06-05T09:54:11+02:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Jun 05 09:54:11 kafka mender[2711]: time="2023-06-05T09:54:11+02:00" level=info msg="State transition: update-check [Sync] -> check-wait [Idle]"
Jun 05 09:54:14 kafka mender[2711]: time="2023-06-05T09:54:14+02:00" level=info msg="State transition: check-wait [Idle] -> inventory-update [Sync]"
Jun 05 09:54:15 kafka mender[2711]: time="2023-06-05T09:54:15+02:00" level=info msg="State transition: inventory-update [Sync] -> check-wait [Idle]"
Jun 05 09:54:16 kafka mender[2711]: time="2023-06-05T09:54:16+02:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Jun 05 09:54:16 kafka mender[2711]: time="2023-06-05T09:54:16+02:00" level=info msg="State transition: update-check [Sync] -> check-wait [Idle]"
Jun 05 09:54:19 kafka mender[2711]: time="2023-06-05T09:54:19+02:00" level=info msg="State transition: check-wait [Idle] -> inventory-update [Sync]"
Jun 05 09:54:20 kafka mender[2711]: time="2023-06-05T09:54:20+02:00" level=info msg="State transition: inventory-update [Sync] -> check-wait [Idle]"
Jun 05 09:54:21 kafka mender[2711]: time="2023-06-05T09:54:21+02:00" level=info msg="State transition: check-wait [Idle] -> update-check [Sync]"
Jun 05 09:54:21 kafka mender[2711]: time="2023-06-05T09:54:21+02:00" level=info msg="State transition: update-check [Sync] -> check-wait [Idle]"
Jun 05 09:54:24 kafka mender[2711]: time="2023-06-05T09:54:24+02:00" level=info msg="State transition: check-wait [Idle] -> inventory-update [Sync]"
Jun 05 09:54:25 kafka mender[2711]: time="2023-06-05T09:54:25+02:00" level=info msg="State transition: inventory-update [Sync] -> check-wait [Idle]"

```

Am I doing something wrong?

I tried also:  
`mender-cli port-forward 3bbe0235-f863-48e9-97e3-dbc1d75fa47g 21000`

still the same.
