python net socket connect fail

socket connect fail will be many reasons.
First you should check the firewall, does it block your socket port which you want to connect, python.exe or pythonw.exe
Second, your server listens host and ip are the same your client socket.
for example.
Your server socket listens host=’localhost’, port=7777, and your client want to connect host=’192.168.12.XXX’, port=7777. They are not same. ‘localhost’ is ‘’, and your client want to connect host=’192.168.12.XXX’. Even there is only one net-adapter and one network configure. So change host which your server socket listened to ‘192.168.12.XXX’.
This error will occur in :

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((‘192.168.12.XXX’,7777)) # here you can not connect server