Sunan Abi Dawud Book 14, Hadith 161
The sunnah for one who is observing i'tikaf (in a mosque) is not to visit a patient, or to attend a funeral, or touch or embrace one's wife, or go out for anything but necessary purposes. There is no i'tikaf without fasting, and there is no i'tikaf except in a congregational mosque.
According to the version of Al Nufaili, A’ishah said “The Prophet (ﷺ) used to pass by a patient while he was observing I’tikaf(in the mosque) but he passed as usual and did not stay asking about him.”
According to the version of Ibn Isa she said “The Prophet (ﷺ) would visit a patient while he was observing I’tikaf.”
Umar (may Allah be pleased with him) took a vow in the pre-Islamic days to spend a night or a day in devotion near the Ka'bah (in the sacred mosque). He asked the Prophet (ﷺ) about it. He said: Observe i'tikaf (i.e. spend a night or a day near the Ka'bah) and fast.