Sunan Ibn Majah, Book 1, Hadith 516 (In-Book)

It was narrated that Safwan bin 'Assal said: "The Messenger of Allah used to command us not to take off our leather socks for three days except in the case of sexual impurity, but not in the case of defecation, urine or sleep (i.e. during travel)."

حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا سُفْيَانُ بْنُ عُيَيْنَةَ، عَنْ عَاصِمٍ، عَنْ زِرٍّ، عَنْ صَفْوَانَ بْنِ عَسَّالٍ، قَالَ كَانَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ يَأْمُرُنَا أَنْ لاَ نَنْزِعَ خِفَافَنَا ثَلاَثَةَ أَيَّامٍ إِلاَّ مِنْ جَنَابَةٍ لَكِنْ مِنْ غَائِطٍ وَبَوْلٍ وَنَوْمٍ ‏.‏

sunnah.com