Repeat the process until you can open the door and the dog remains sitting. Only then may you let your friend in, at no time allow this person to make a fuss of the dog - they must ignore him. After a while your dog will learn that only good behaviour means seeing a visitor. This also can be used to train your dog not to go out an open gate etc. Do not leave him in the garden area unsupervised until he has been properly trained, or he will learn that he can still do want he wants when you're not around.
Some dogs have phobias such as fear of the vacuum cleaner, thunder or other loud noises.
It is possible that at some stage he has had a genuine fright or that he was never introduced to say a vacuum cleaner until he was past the puppy stage. In the case of a vacuum cleaner, start by turning the machine on when in a different room to the dog - so he can only just hear it. Over a period of time move it closer so that eventually you can turn it on in the same room. When you do this leave it turned on while you give your dog its dinner. He will ignore the sound and eat.