# Stuck devices - "tunneling socket could not be established: cause=socket hang up"

**URL:** <https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113>\
**Category:** Product support\
**Created:** [January 28, 2019, 6:57pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113 "2019-01-28T18:57:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![troyvsvs](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@troyvsvs](https://forums.balena.io/u/troyvsvs)\
**Post date:** [January 28, 2019, 6:57pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/1 "2019-01-28T18:57:34Z")

</div>

Hi,

We’ve had approximately 2-3 remote production devices go into a weird state in which our application containers stop running, but devices show as “Online” in the balena website.

The “weird state” is characterized by: containers appear to be not running (no balena logs and no internal logs to our infrastructure). Issuing a restart command from the website is responded to with "“tunneling socket could not be established: cause=socket hang up” message displayed, and restart is unsuccessful. Issuing a reboot command from the website is similarly unsuccessful, with the same error message displayed. We discovered that we were able to SSH into the “Host OS” and run “shutdown -r now”, and this seemed to fully restore the devices to operational status. This has been observed on balenaOS 2.29.0+rev1 supervisor 9.0.1. and possibly other versions.

Why is this happening, and how can we prevent it from happening? What can we look into?

---

<div class="post-metadata">

**Author:** ![samothx](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samothx](https://forums.balena.io/u/samothx)\
**Post date:** [January 28, 2019, 10:59pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/4 "2019-01-28T22:59:42Z")

</div>

Hi,  
I have not heard of this type of behaviour so we will have to take a look when it occurs again.  
Best option would be to contact support as soon as you find a device in that state and enable support access. You will have to give us a little time to take care, depending on the amount of active support issues.  
Unfortunately most relevant logs are not available any more after reboot so there is not much we can see once the device has booted. If you share a device link and enable support access I can take a look anyway and see if I can detect anything unusual.  
Regards  
Thomas

JAN 29, 11:44 AM

---

<div class="post-metadata">

**Author:** ![troyvsvs](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@troyvsvs](https://forums.balena.io/u/troyvsvs)\
**Post date:** [January 29, 2019, 1:24am UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/5 "2019-01-29T01:24:08Z")

</div>

Hi Thomas,  
Thanks for the info. We’ll do our best to try to forward you support access to a device that gets into this state the next time we see it.

---

<div class="post-metadata">

**Author:** ![troyvsvs](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@troyvsvs](https://forums.balena.io/u/troyvsvs)\
**Post date:** [January 29, 2019, 1:28am UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/6 "2019-01-29T01:28:08Z")

</div>

Out of curiosity, is there any way for us to go in and capture the low level system logs ourselves? Maybe we can look at them too without requiring the full support access option.

---

<div class="post-metadata">

**Author:** ![robertgzr](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/robertgzr/32/1387_2.png) [@robertgzr](https://forums.balena.io/u/robertgzr)\
**Post date:** [January 29, 2019, 12:50pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/7 "2019-01-29T12:50:44Z")

</div>

hey @troyvsvs you should have the option on the dashboard to login to the host os. Once there you can use the standard tools to look around…

---

<div class="post-metadata">

**Author:** ![msegado](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@msegado](https://forums.balena.io/u/msegado)\
**Post date:** [February 4, 2019, 4:21am UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/8 "2019-02-04T04:21:19Z")

</div>

I’ve also seen these exact symptoms; @samothx, I left one of my devices in this “stuck” state and granted support access so y’all can poke around: [https://dashboard.balena-cloud.com/devices/d1ed939d7e2a7e1a4c14a0c791505d27/](https://dashboard.balena-cloud.com/devices/d1ed939d7e2a7e1a4c14a0c791505d27/)

---

<div class="post-metadata">

**Author:** ![hedss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hedss/32/210_2.png) [@hedss](https://forums.balena.io/u/hedss)\
**Post date:** [February 4, 2019, 10:42am UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/21 "2019-02-04T10:42:20Z")

</div>

Hello there @msegado,

We’ve looked into the device @msegado kindly granted access support for, and we’ve determined the reason for failure is because the balenaEngine binary has become corrupted (amongst other files). This appears be down to SD card corruption.

We’ve also noticed the kernel ring journal shows a constant stream of the following errors:

```auto
[589909.286836] usb 1-1-port2: over-current change

```

This points to either an issue with the power supply (eg. not using a powerful enough supply) or an issue with the USB ports themselves. The following thread gives you a little more information:

[https://www.element14.com/community/thread/55091/l/how-to-get-rid-of-over-current-change?displayFullThread=true](https://www.element14.com/community/thread/55091/l/how-to-get-rid-of-over-current-change?displayFullThread=true)

These two factors combined appear to point to power issues which have caused SD card corruption corrupting several required binaries.

We’re attempting to fix this device manually, but please be aware if there are power issues on this device, the likelihood of this happening again are quite high.

Best regards, Heds

---

<div class="post-metadata">

**Author:** ![hedss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hedss/32/210_2.png) [@hedss](https://forums.balena.io/u/hedss)\
**Post date:** [February 4, 2019, 1:45pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/28 "2019-02-04T13:45:13Z")

</div>

Hi again,

Just as an aside, we strongly recommend using an SD card that’s been rigorously tested, such as the SanDisk Extreme Pro. We often see customers with SD corruption due to cheap SD cards.

Best regards, Heds

---

<div class="post-metadata">

**Author:** ![troyvsvs](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@troyvsvs](https://forums.balena.io/u/troyvsvs)\
**Post date:** [February 4, 2019, 6:35pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/30 "2019-02-04T18:35:14Z")

</div>

This doesn’t seem to address the obvious: we were able to get the devices working again by running “shutdown -r now” on the host OS. How can that possibly square with the “SD corruption”?

---

<div class="post-metadata">

**Author:** ![samothx](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samothx](https://forums.balena.io/u/samothx)\
**Post date:** [February 5, 2019, 1:36am UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/31 "2019-02-05T01:36:21Z")

</div>

Hi  
SD-card corruption can manifest itself in a lot of ways. Depending on where corruption is located you can expects all sorts of weird behaviours.  
Regards  
Thomas

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [February 5, 2019, 2:11am UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/35 "2019-02-05T02:11:31Z")

</div>

@troyvsvs, the device that we know had SD corruption was @msegado’s. If you’re seeing the device come back fine after a reboot then it’s probably a different issue.

You had asked how you can get low level logs yourselves - there’s several things that could be useful to diagnose, but in this case I think these would be the most relevant:

```auto
systemctl status resin-supervisor.service
journalctl -n 500 -u resin-supervisor -a
systemctl status balena.service
journalctl -n 500 -u balena -a
balena ps -a
balena images
dmesg

```

This is because I suspect the supervisor isn’t running properly, given how the restart command is failing. I’m hoping we can see some useful error messages if you post the output of those commands (especially the journalctl ones).

---

<div class="post-metadata">

**Author:** ![msegado](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@msegado](https://forums.balena.io/u/msegado)\
**Post date:** [February 5, 2019, 7:29pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/38 "2019-02-05T19:29:00Z")

</div>

Thanks for looking into (and fixing!) this. While we’re not running any USB devices, both our SD cards and our PSUs were very cheap (rated at 2.5A but not verified…) so one of those seems like a likely culprit. I’ll look into replacing those.

That said, the last time this happened I was also able to reboot from the CLI like @troyvsvs and have the device come back online, so I’m wondering if there’s more going on here. I’m not too familiar with how the disk cache operates in Linux, but is it possible that the cache became corrupt due to power issues rather than the filesystem itself (and just never got invalidated since it’s read-only)? In that case the corruption would fix itself after a reboot.

Anyway, I’ll keep an eye out and let you all know if I get a device stuck in this state again so we can experiment more =)

---

<div class="post-metadata">

**Author:** ![troyvsvs](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@troyvsvs](https://forums.balena.io/u/troyvsvs)\
**Post date:** [February 5, 2019, 7:46pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/39 "2019-02-05T19:46:26Z")

</div>

@pcarranzav

Those commands are very helpful thanks. We’ll run them (in addition to providing support access) if this is seen again.

To all balena folk on here: is there any way we can gather these low level logs from our application container? We have a fairly robust internal log infrastructure that might be useful in debugging this stuff if we could forward the OS logs to it. We could, e.g., give you guys logs going back a week or more.

@msegado  
Thanks for the update and info about your ability to reboot. My hunch is that there’s something else going on here. Your disk cache explanation is a logical argument but it seems a stretch to justify the SD corruption as the culprit. I’m not aware of a corruptible read only disk cache (living somewhere between nonvolatile cells and RAM) as you’re describing. It seems that if power is too low to hold things in volatile memory, even RAM would be affected. Could be wrong on that though. Another thing is that we saw a spurt of devices encountering this issue immediately after a large portion of our fleet experienced a network outage. I guess that “network outage” could have been a power outage though. Random power outages might cause any power-related instability to surface.

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [February 5, 2019, 11:28pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/43 "2019-02-05T23:28:35Z")

</div>

@troyvsvs, regarding: _“is there any way we can gather these low level logs from our application container?,”_ to the best of my knowledge unfortunately the answer is no. This request/question pops up every now and then, and every time it does, it gets upvoted in our internal issue tracker and discussed in our roadmap meetings, so thank you for bringing it up!

---

<div class="post-metadata">

**Author:** ![dt-rush](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/dt-rush/32/1405_2.png) [@dt-rush](https://forums.balena.io/u/dt-rush)\
**Post date:** [February 6, 2019, 4:22pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/44 "2019-02-06T16:22:04Z")

</div>

Are the devices all on a common power infrastructure? If the issue was correlated with an outage on network as well, and they are on a common power infrastructure, it seems possible that power fluctuation is a variable that could connect network outage to any disk / memory corruption.

Also, could you clarify which kinds of logs you’d like to gather from the application containers? It may be possible to include a logging export agent in your application image for the logs you want.

---

<div class="post-metadata">

**Author:** ![troyvsvs](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@troyvsvs](https://forums.balena.io/u/troyvsvs)\
**Post date:** [February 7, 2019, 8:49pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/45 "2019-02-07T20:49:19Z")

</div>

@pdcastro  
You’re welcome. Thanks for hopping on, and for the insight into Balena’s development processes.

@dt-rush  
We aren’t sure exactly the topology of the power infrastructure at our install locations, but several of the devices were in the same building.

As to which kinds of logs we’d like to gather, we’d like to gather any logs that can help Balena or us debug stability issues and improve the core OS, or knowledge of the interaction between application containers and the OS for maximum reliability. Eventually we want or IoT service to reach \> 99.9% uptime, and in the future numbers like that _will_ be a requirement for us, so I want to do whatever I can to boost the reliability numbers. Any or all logs useful to achieving that can be accommodated.

---

<div class="post-metadata">

**Author:** ![nuno\_martins1](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@nuno\_martins1](https://forums.balena.io/u/nuno_martins1)\
**Post date:** [October 3, 2019, 4:41pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/46 "2019-10-03T16:41:34Z")

</div>

Hy, I am having this problem rigth now. I try to runn the command “shutdown -r now” but did not solve the problem.

It is possible to get suport from balena team? I was already enable the support access.

Thanks a lot

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [October 3, 2019, 5:20pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/49 "2019-10-03T17:20:12Z")

</div>

@nuno_martins1, I’ve sent you a private e-mail that you can reply with your device UUID or web dashboard URL, as we need that in addition to the granting of support access to the device.

---

<div class="post-metadata">

**Author:** ![nuno\_martins1](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@nuno\_martins1](https://forums.balena.io/u/nuno_martins1)\
**Post date:** [October 3, 2019, 6:08pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/51 "2019-10-03T18:08:57Z")

</div>

> [@pdcastro](#):
>
> sent you a private e-mail that you can reply with your device UUID or web dashboard URL, as we need that in addition to the granting of support access to the device.

right: my UUID is 8b2b584c18961f602b82e38865d1be3e.

This probles was happedesd in the past and I was replace the memory card. But the device is far away. I wold like to had another kind of solution.

---

<div class="post-metadata">

**Author:** ![pdcastro](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pdcastro/32/1264_2.png) [@pdcastro](https://forums.balena.io/u/pdcastro)\
**Post date:** [October 3, 2019, 6:59pm UTC](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113/65 "2019-10-03T18:59:21Z")

</div>

@nuno_martins1, thanks for sharing the device UUID and granting support access. I was looking at the device logs and I see that balena-engine and the balena supervisor are failing to start because of filesystem issues:

```auto
# on a host OS prompt
root@8b2b584:~# journalctl -xe
...
Oct 03 18:43:35 8b2b584 kernel: EXT4-fs error (device mmcblk0p6): ext4_lookup:1587: inode #2925: comm balenad: deleted inode referenced: 1573070
Oct 03 18:43:35 8b2b584 kernel[637]: [7829.876197] EXT4-fs error (device mmcblk0p6): ext4_lookup:1587: inode #2925: comm balenad: deleted inode referenced: 1573070
Oct 03 18:43:35 8b2b584 balenad[7509]: time="2019-10-03T18:43:35.916044766Z" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd
Oct 03 18:43:35 8b2b584 balenad[7509]: time="2019-10-03T18:43:35.916334712Z" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd nam>
Oct 03 18:43:36 8b2b584 balenad[7509]: Error starting daemon: lstat /var/lib/docker/image/aufs/layerdb/sha256/dc34b7df1552b76c451b24f9c42c5b0364005fc166360901d436eca93f0935cb: structure needs c>
Oct 03 18:43:36 8b2b584 systemd[1]: balena.service: Main process exited, code=exited, status=1/FAILURE
Oct 03 18:43:36 8b2b584 systemd[1]: balena.service: Failed with result 'exit-code'.
Oct 03 18:43:36 8b2b584 systemd[1]: Failed to start Balena Application Container Engine.
Oct 03 18:43:37 8b2b584 systemd[1]: balena.service: Service RestartSec=100ms expired, scheduling restart.
Oct 03 18:43:37 8b2b584 systemd[1]: balena.service: Scheduled restart job, restart counter is at 5.
Oct 03 18:43:37 8b2b584 systemd[1]: Stopped Balena Application Container Engine.
Oct 03 18:43:37 8b2b584 systemd[1]: Closed Docker Socket for the API.
Oct 03 18:43:37 8b2b584 systemd[1]: Stopping Docker Socket for the API.
Oct 03 18:43:37 8b2b584 systemd[1]: balena-engine.socket: Start request repeated too quickly.
Oct 03 18:43:37 8b2b584 systemd[1]: balena-engine.socket: Failed with result 'start-limit-hit'.
Oct 03 18:43:37 8b2b584 systemd[1]: Failed to listen on Docker Socket for the API.
Oct 03 18:43:37 8b2b584 systemd[1]: Dependency failed for Balena Application Container Engine.
Oct 03 18:43:37 8b2b584 systemd[1]: balena.service: Job balena.service/start failed with result 'dependency'.

```

```auto
root@8b2b584:~# journalctl -au resin-supervisor
...
Oct 03 18:31:29 8b2b584 resin-supervisor[6828]: Unhandled rejection Error: (HTTP code 500) server error - layer does not exist
...

```

The web dashboard Diagnostics tab (Supervisor State) for the device says _“error: tunneling socket could not be established, cause=socket hang up”_ because the supervisor is not running on the device, which in turn is caused by the filesystem issues.

Such filesystem corruption issues are most commonly caused by SD card failures, or power outages. If you cannot replace the SD card, it may be possible to remotely unmount the `/mnt/data` partition and run `fsck` on it. Is this something you would like me to try? There is a risk of further data loss on the device.

[Next page](https://forums.balena.io/t/stuck-devices-tunneling-socket-could-not-be-established-cause-socket-hang-up/5113.md?page=2)
