'unknown encoding: idna' on socket.connect()


On a CP X4 I am running a Python routine that attempts to open a socket to port 502 on localhost (to the IA module) and read from it.

A standalone test version works fine.

Called from a larger program (which is also doing some HTTP POSTing to an external server), the same code gets an ‘unknown encoding: idna’ on socket.connect().

Appears I am sensitizing something that causes the idna encoding error.

There was a previous post by someone encountering this error using httplib. Solution was to use digi_httplib. That doesn’t seem to be what is happening here.

Anyone seen such behavior?


  • C

I seem to have solved this problem. On a hunch, I checked the type of the host name being presented to the socket connect. It was unicode. I made it str, and now the socket opens without problem.

  • C


see above --^

I believe the response has now moved to here…and thank you to all involved in solving and writing about this!