The magnetic field lines exist outside the solenoid, but the number of field lines per unit area (flux) outside the solenoid is much less compared to the number of lines per unit area (flux) inside the solenoid. Hence the magnetic field outside is so weak that it is considered to be practically zero. If the solenoid is very long than it is more true to consider magnetic field outside the solenoid to be zero. Near the edge of the solenoid it is not true. For practical purpose we take magnetic field outside the solenoid to be zero