Django response can’t connect to TVP listener running on localhost.

I have a Django application running on an embedded device that runs a Linux image. Forgive me for not having the specifics of versions and builds, I am not at work. Gunicorn is used as a web server. My web page is available at a static IP of https://192.168.1.40:81

As part of the backend for an Ajax Post submission,
My python connects to a loclahost (127.0.0.1) tcp listener that was coded in C and runs on the Linux. It listens on localhost port 5456. My connection to it is on the same localhost ip and port.

When I use python to open a shell and import my Django env, sockets, my “client” code, etc, I can execute my scrips manually and successfully connect to the listener and send packets of data to it. Works great.

However, when I have the http response python execute the same tcp code I used in manual testing, when a user submits data from the web page, I get a connection refused error back from my connection attempt.

Anyone have any ideas on what I could check? I tested my python manually in a shell and it’s happy as can be.

Is this a permission issue or a Django limitation or setting?

There’s not enough information here to begin to diagnose this.

At a minimum, we’d need to see the code that you’re using to try and do this, along with the complete error and traceback being generated. (If you’re doing this from within a runserver instance, you should see that in the console where you’re running runserver.

Supplying the code that you’re running in the shell manually would also be helpful in addition to what you’re trying to do in Django.