And Jesus said to him, “Foxes have holes, and birds of the air have nests, but the Son of Man has nowhere to lay his head.”
Jesus turned and saw them following and said to them, “What are you seeking?” And they said to him, “Rabbi” (which means Teacher), “where are you staying?” He said to them, “Come and you will see.” So they came and saw where he was staying, and they stayed with him that day, for it was about the tenth hour.
In Matthew 8:20, Jesus is talking about the cost of discipleship, in this case giving up your home. The reference to birds’ nests and foxes’ holes indicates that Jesus was talking about permenent dwelling (i.e. a home) rather than temporary accommodation. John 1:38-39 refers to Jesus “staying” somewhere, i.e. he was only there temporarily. So there is no contradiction — Jesus had no permanent dwelling during the time of his ministry.