In the case of infinite length solenoid, magnetic field lines have very large loop. So, there is no magnetic field lines just outside the solenoid and hence zero magnetic filed.
In the case of finite length solenoid, magnetic field never be zero outside the solenoid. There are few magnetic field lines just outside the solenoid, but there effect is negligible.
So, we don't consider any magnetic field in both cases.
Study 40% syllabus and score up to 100% marks in JEE