ranger has multiple IP addresses. One of them is refusing connections. Try running the cog and swift examples you gave three or four times and see if the behaviour is consistent. --