# TCP connection error , port 443 N: Connect failed errno=13

**URL:** <https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276>\
**Category:** Legato Application Framework\
**Created:** [June 29, 2020, 6:33am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276 "2020-06-29T06:33:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaielavrupa](https://avatars.discourse-cdn.com/v4/letter/z/dc4da7/32.png) [@zaielavrupa](https://forum.legato.io/u/zaielavrupa)\
**Post date:** [June 29, 2020, 6:33am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/1 "2020-06-29T06:33:47Z")

</div>

I am getting the following error in the logread when my Legato application is trying to connect to another server application on the device (which is not in the legato system) via port 443. My adef file has `sandboxed: false` and the application is being started by an init script. Only this script is kept in the package. When I run my application outside the legato system i.e without starting from legato - I don’t face an issues to connect via port 443 to the server application.

device is FX30s  
legato version : 16.10.1  
Application: Legacy C application ported for this device

adef file:

> sandboxed: false
> 
> bundles:  
> {  
> file:  
> {  
> [xr] Init.sh /bin/
> 
> }
> 
> }
> 
> requires:  
> {  
> file:  
> {  
> /bin/sh /bin/sh  
> /etc/hosts /etc/  
> }
> 
> }
> 
> processes:  
> {  
> envVars:  
> {  
> LD\_LIBRARY\_PATH=/path/to/required/Libs/for\_my\_Legacy\_application  
> }
> 
> run:  
> {  
> (Init.sh)  
> }
> 
> maxCoreDumpFileBytes: 100K  
> maxFileBytes: 20480K  
> //faultAction: restart
> 
> }
> 
> maxMemoryBytes: 90440K
> 
> start: auto

ERROR:  
`fx30s user.err Legato: =ERR= |Init.sh[26707] | [2020/06/29 06:22:06:7588] N: Connect failed errno=13`

I read from [this](https://forum.legato.io/t/socket-connection-timeout-but-ack-received/3482/2) post that, USB interface does not have much restrictions regarding iptable rules, since sandboxed is set to false I am assuming my app is getting root privileges as well, so I am out of ideas as to why the connection is not working inside the legato system and works properly outside.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 29, 2020, 7:45am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/2 "2020-06-29T07:45:20Z")

</div>

you can shut down the firewall by the following command and see if the problem still exists.  
iptables -I INPUT -j ACCEPT

Also you can put your script in /tmp, and then using system(“sh /tmp/Init.sh”); in the code and see if the problem still exists.

---

<div class="post-metadata">

**Author:** ![zaielavrupa](https://avatars.discourse-cdn.com/v4/letter/z/dc4da7/32.png) [@zaielavrupa](https://forum.legato.io/u/zaielavrupa)\
**Post date:** [June 29, 2020, 9:26am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/3 "2020-06-29T09:26:40Z")

</div>

@jyijyi Thanks for the reply. Shutting down the firewall did not help.  
And I did not understand what you meant by putting the init script in the /tmp - do you mean in the legato package?

My scenario is I am using an Init script to start my C application. When I run the script outside legato I have no issues, when i run the script from legato - I am facing the issues. I am only using the script so that I can start my applications from legato, but keep all the required files and stuff in other locations. Also the app is not sandboxed.

I ran into another post that seem to have had a similar scenario: [THIS](https://forum.legato.io/t/application-group-for-tcp-ip-communication-permission/2838) But their issue was solved by changing from ipv6 to ipv4.

In my case, if i do `netstat -ent` , I am getting the following output:  
`tcp 0 1 127.0.0.1:36211 127.0.0.1:443 SYN_SENT`  
But then the app gets killed after some time  
Is this due to some setting/permission issue that I have missed. I am very new to Legato.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 29, 2020, 9:39am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/4 "2020-06-29T09:39:57Z")

</div>

no, /tmp is the real path in the module as a result, your legato application can run the shell script in /tmp/Init.sh by system() API.

---

<div class="post-metadata">

**Author:** ![zaielavrupa](https://avatars.discourse-cdn.com/v4/letter/z/dc4da7/32.png) [@zaielavrupa](https://forum.legato.io/u/zaielavrupa)\
**Post date:** [June 29, 2020, 10:08am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/5 "2020-06-29T10:08:10Z")

</div>

moving the script to /tmp did not help. Im still getting the error  
`Jun 29 10:01:30 fx30s user.err Legato: =ERR= | startapp[18601] | [2020/06/29 10:01:30:6562] N: Connect failed errno=13`

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 29, 2020, 10:38am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/6 "2020-06-29T10:38:39Z")

</div>

Please attach your script here

---

<div class="post-metadata">

**Author:** ![zaielavrupa](https://avatars.discourse-cdn.com/v4/letter/z/dc4da7/32.png) [@zaielavrupa](https://forum.legato.io/u/zaielavrupa)\
**Post date:** [June 29, 2020, 10:53am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/7 "2020-06-29T10:53:46Z")

</div>

Below given is my init script

```
#!/bin/sh
 cd /home/root/MYLEGACYAPP
./mylegacyapp

```

I also tested with [this example](http://fm4dd.com/openssl/sslconnect.shtm), where I added the url to /etc/hosts as:  
`192.168.2.2 www.hp.com`

Here also, it is having the same behaviour, will connect to the server when run outisde legato, and would not connect when run from legato.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 29, 2020, 11:11am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/8 "2020-06-29T11:11:32Z")

</div>

I will make a try tomorrow, my first thought is similar issue to this one

> [@Ssh tunnel : permission denied](https://forum.legato.io/t/ssh-tunnel-permission-denied/5177):
>
> Hello everyone, I’ve an application [myapp] in legacy C comming from another product. It’s not sandboxed but I’ve a permission issue when I ask it to make an ssh tunnel. I was able to reproduce only without any software code : in /home/root : create a test.sh script - with 755 permissions. #!/bin/sh cd /home/root; export DROPBEAR\_PASSWORD="\<mypassword\>"; /usr/bin/ssh -N -R 60000:localhost:22 \<myUser\>@192.168.2.3 then run it in app context : root@swi-mdm9x28-wp:~# app runProc myapp --exe=/…

Btw, if you change the line ./mylegacyapp to use curl command, does it work?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [June 30, 2020, 2:32am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/9 "2020-06-30T02:32:39Z")

</div>

I don’t see problem with the latest FW R17:

[https://source.sierrawireless.com/resources/airlink/software\_downloads/fx30-firmware/fx30-firmware-3g/#sthash.cEmNgXK3.2jGjhTZT.dpbs](https://source.sierrawireless.com/resources/airlink/software_downloads/fx30-firmware/fx30-firmware-3g/#sthash.cEmNgXK3.2jGjhTZT.dpbs)

Here is my binary of sslconnect\_arm.

[sslconnect\_arm](https://forum.legato.io/uploads/short-url/oOWMVTB8S2BbiKEtxTOzkwwZzJR) (14.7 KB)  
And also I used the following in the unsandboxed legato application:  
system(“/home/root/sslconnect\_arm”);

I can see the following legato log:

* * *

Jun 30 02:27:36 | hello6[1870] | | Successfully made the TCP connection to: [https://www.sierrawireless.com](https://www.sierrawireless.com). Successfully enabled SSL/TLS session to: [https://www.sierrawireless.com](https://www.sierrawireless.com). Retrieved the server’s certificate from: [https://www.sierr](https://www.sierr)  
Jun 30 02:27:36 | hello6[1870] | | ta: [CN=ssl425269.cloudflaressl.com](http://CN=ssl425269.cloudflaressl.com) Finished SSL/TLS connection with server: [https://www.sierrawireless.com](https://www.sierrawireless.com).

* * *

---

<div class="post-metadata">

**Author:** ![zaielavrupa](https://avatars.discourse-cdn.com/v4/letter/z/dc4da7/32.png) [@zaielavrupa](https://forum.legato.io/u/zaielavrupa)\
**Post date:** [July 6, 2020, 4:59am UTC](https://forum.legato.io/t/tcp-connection-error-port-443-n-connect-failed-errno-13/5276/10 "2020-07-06T04:59:36Z")

</div>

Updating to latest firmware solved the tcp issue. Thank you for your time @jyijyi
