Whosoever transgresseth, and abideth not in the doctrine of Christ, hath not God. He that abideth in the doctrine of Christ, he hath both the Father and the Son. -2 John 1:9
If there come any unto you, and bring not this doctrine, receive him not into your house, neither bid him God speed: -2 John 1:10
For he that biddeth him God speed is partaker of his evil deeds. -2 John 1:11
He is talking about those who claim to be religious teachers that teach heresy about the person and work of Jesus Christ and what Jesus taught.
This passage is not saying that we should shun those who hold different religious views than our own. Of course we should be a Good Samaritan to them, like we would anyone else if we came upon them in dire straits.
We are not to invite them into our homes and encourage them in their errant teaching.
There is some disagreement as to whether or not it's okay to invite them in for the express purpose of showing them where they are wrong. In the case of those teachers who go door to door in pairs teaching false doctrine, I have heard of quite a few who because they were invited in, treated with kindness and shown the error of their doctrine, actually came to saving faith in Him.
One commentary suggested that the point here is that you don't invite them in just for the sake of hospitality and tell them, "God bless you!" as they leave. That would be a stamp of approval on what they are doing.
Apparently, that is what the Elect Lady to whom this letter was written to was doing.
A case for taking this admonition literally would the fact that your neighbors don't know for what purpose you are inviting them in and might take it as your stamp of approval on what they teach, thereby being led astray.
I used to invite them in to show them where they were wrong, but no longer do that. I'm realizing that it is better to keep the discussion on the doorsteps where observing neighbors will see they are not being invited in and not be confused by what looks like approval of them.