A grid blackout is an intractable problem with serious economic consequences in many developing countries. Although it has been proven that microgrids (MGs) are capable of solving this problem, the uncertainties regarding when and for how long blackouts occur lead to extreme difficulties in the design and operation of the related MGs. This paper addresses the optimal design problem of the MGs considering the uncertainties of the blackout starting time and duration utilizing the kernel density estimator method. Additionally, uncertainties in solar irradiance and ambient temperature are also considered. For that, chance-constrained optimization is employed to design residential and industrial PV-based MGs. The proposed approach aims to minimize the expected value of the levelized cost of energy (LCOE), where the restriction of the annual total loss of power supply (TLPS) is addressed as a chance constraint. The results show that blackout uncertainties have a considerable effect on calculating the size of the MG’s components, especially the battery bank size. Additionally, it is proven that considering the uncertainties of the input parameters leads to an accurate estimation for the LCOE and increases the MG reliability level.