The problem is due to improper configuration on nifi.properties
Please make sure: you have following properties in nifi-1.4.0/conf/nifi.properties:
# Site to Site properties
nifi.remote.input.host=192.168.2.8 # Previously it was localhost when I was getting error
nifi.remote.input.socket.port=10000 # Your destination machine should have allowed this port