Let’s compare.
FAILED case:
[pid 2683] socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 19
[pid 2683] connect(19, {sa_family=AF_INET, sin_port=htons(21325), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
[pid 2683] mprotect(0x3e03000, 245760, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
[pid 2683] mprotect(0x3e03000, 245760, PROT_READ|PROT_EXEC) = 0
[pid 2683] epoll_ctl(13, EPOLL_CTL_ADD, 19, {events=EPOLLOUT, data={u32=19, u64=19}}) = 0
[pid 2683] epoll_wait(13, [{events=EPOLLIN, data={u32=16, u64=16}}, {events=EPOLLOUT|EPOLLERR|EPOLLHUP, data={u32=19, u64=19}}], 1024, 0) = 2
[pid 2683] read(16, "\1\0\0\0\0\0\0\0", 1024) = 8
[pid 2683] mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f0cbeff0000
[pid 2683] munmap(0x7f0f3eff0000, 61440) = 0
[pid 2683] mprotect(0x7f0d3eff0000, 655360, PROT_READ|PROT_WRITE) = 0
[pid 2683] getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
[pid 2683] epoll_ctl(13, EPOLL_CTL_DEL, 19, 0x7ffcf95c8404) = 0
SUCCESSFUL case:
[pid 4164659] connect(21, {sa_family=AF_INET, sin_port=htons(21325), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
[pid 4164659] mprotect(0x4bc3000, 245760, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
[pid 4164659] mprotect(0x4bc3000, 245760, PROT_READ|PROT_EXEC) = 0
[pid 4164659] epoll_ctl(13, EPOLL_CTL_ADD, 21, {events=EPOLLOUT, data={u32=21, u64=21}}) = 0
[pid 4164659] epoll_wait(13, [{events=EPOLLIN, data={u32=16, u64=16}}, {events=EPOLLOUT|EPOLLERR|EPOLLHUP, data={u32=21, u64=21}}], 1024, 0) = 2
[pid 4164659] read(16, "\2\0\0\0\0\0\0\0", 1024) = 8
[pid 4164659] write(18, "Ledger app version 4.1.2\n", 25) = 25
They using O_NONBLOCK socket, then epoll to catch the moment when connection is established. So, on failed case we’ve got ECONNREFUSED. In successful case we’ve successful connection.
I think we you need somehow to get straces of the trezord, so we can determine why it fails.