It is narrated from Ibn Abbas (may Allah be pleased with them both) that he said: I heard the Messenger of Allah (ﷺ) say in a sermon: "No man should be alone with a woman, and it is not permissible for a woman to travel except with a mahram (close male relative)." A man stood up and said: "O Messenger of Allah! My name has been registered for such-and-such battle, while my wife has gone for Hajj?" The Prophet (ﷺ) said: "Go and perform Hajj with your wife."
Hadith Referenceمسند الإمام الشافعي / كتاب الحج / 852
Hadith Takhrijاخرجه البخارى، جزاء الصيد، باب حج الصبيان (1862) ومسلم ، الحج، باب سفر المرأة مع محرم الى حج وغيره (1341)۔