I'd say that the
Try to run the code using the same account you use for GUI (
UserCustomServices account does not have an access to network allowed.
Try to run the code using the same account you use for GUI (
Administrator).