in reply to
Socket connection refused problem
If you do "ping localhost" you'll see which IP address is really used. Normally it is 127.0.0.1 which is the address that is used only within the same machine. Using this address you can't connect from one machine to another. For this each machine must have another IP address, and if everything is setup correctly, then the name associated with that address is reported by command 'hostname'.
So, just make sure that both scripts use the same IP address, and that IP address is not the "local" one.