Bulugh al-Maram #826
كتاب الحج
وَعَنْهُ: سَمِعْتُ رَسُولَ اَللَّهِ - صلى الله عليه وسلم -يَخْطُبُ يَقُولُ: «لَا يَخْلُوَنَّ رَجُلٌ بِاِمْرَأَةٍ إِلَّا وَمَعَهَا ذُو مَحْرَمٍ, وَلَا تُسَافِرُ اَلْمَرْأَةُ إِلَّا مَعَ ذِي مَحْرَمٍ» فَقَامَ رَجُلٌ, فَقَالَ: يَا رَسُولَ اَللَّهِ, إِنَّ اِمْرَأَتِي خَرَجَتْ حَاجَّةً, وَإِنِّي اِكْتُتِبْتُ فِي غَزْوَةِ كَذَا وَكَذَا, قَالَ: «اِنْطَلِقْ, فَحُجَّ مَعَ اِمْرَأَتِكَ» مُتَّفَقٌ عَلَيْهِ, وَاللَّفْظُ لِمُسْلِمٍ
Ibn 'Abbas (RAA) narrated, ‘I heard the Messenger of Allah (ﷺ) saying, “A man must never be alone with a woman unless there is a Mahram with her. A woman also may not travel with anyone except with a Mahram (relative).” A man stood up and asked, ‘O Messenger of Allah! My wife has gone for Hajj while I am enlisted for such and such a battle, what should I do?’ The Messenger of Allah (ﷺ) replied, “Go and join your wife in Hajj.” Agreed upon, and the wording is from Muslim.