The Messenger of Allah ﷺ used to instruct us that when we were traveling, we should not remove our leather socks for three days and three nights, except in the case of major ritual impurity. As for relieving oneself or sleeping, we were not required to remove them.
حدثنا هناد حدثنا أبو الأحوص عن عاصم بن أبي النجود عن زر بن حبيش
كان رسول الله ﷺ يأمرنا إذا كنا سفرا أن لا ننزع خفافنا ثلاثة أيام ولياليهن إلا من جنابة ولكن من غائط وبول ونوم
[Its chain is hasan]. Ibn Majah also narrated it in the Book of Purification, Chapter on wudu after sleep, no. 478, from the hadith of Asim through the same route. Ibn Hibban graded it sahih (al-Ihsan): 1097, as did Ibn Khuzayma, nos. 17, 193, 196.The hadith of Zaida bin Qudama is sahih. Bayhaqi narrated it: 1/277.