Oops, if it's actually on the loopback interface it won't accept connections from other interfaces which is less of a surprise.
(Got muddled up between Python code which wasn't working as expected and version written in C to make sure I understood the underlying interface.)