tcp connection refused Error 10061

  • I'm developing a Python Kodi addon that utilizes a client/server model. The addon works under Windows but when I install it on my Raspberry Pi (LE 8.2.1), I get the following error:"tcp connection refused Error 10061". I ran netstat and could see that my socket was Listening on the port I assigned.

    To eliminate anything with Kodi, I wrote a set of simple client/server scripts in Python clientServerTest.zip. I got the same error when I ran the server code from the command line on the RPi and tried to connect to it using the client script on an external computer. Again, netstat showed the port I used being listened to.

    My question is how can I enable the tcp port I have chosen so that I can access my server? Any help or suggestions will be greatly appreciated.

  • So I did some research and discovered the iptables command that is suppose to control the firewall.

    iptables -S shows no rules so I don't know why the RPi is rejecting the tcp connection.

    Anyway, I issued the following command to add a rule:

    iptables -A INPUT -p tcp -m tcp --dport 51000 -j ACCEPT

    It appears that the rule is being ignored because it did not allow me to connect to the server code running on the RPi from my Windows PC that was running the client.

    I ran the same test on my Ubuntu PC and it worked with no problem.

    Any suggestions for resolving this issue will be greatly appreciated.

  • Hi chewitt I've tried to connect from a Windows 10 PC as well as from othe RPis on the same network and got the same result.

    Is there some other mechanism installed that is only allowing Kodi related ports to be open?

  • Nope. Our default config is wide open. It will change in LE9 so iptables restricts inbound connections to RFC1918 networks, but that still wouldn't explain why you cannot connect from a local network.

    Hi chewitt,

    I finally figured out what was going on. The Python interpreter in LE does not recognize the hostname 'localhost'. In my test script, changing host='localhost' to host='' fixes the problem.

    My Windows version of Python 2.7 does not suffer from this problem. Yes, I can successfully ping 'localhost' from the command line but binding a socket with 'localhost' causes the connection refused error problem I reported.