This turned out to be a loop back problem, I was trying to scan a a folder on the same domain which was not allowed with my host.
I've had to introduce a 'state' to deal with this which says whether the software is live or not (because the software, once live, will actually point to a different domain).