This paper presents a stochastic mixed-integer linear mathematical model for finding the optimal placement and sizing of distributed generation in a DC distribution network, considering the uncertainty of electrical demand and distributed renewable sources. The proposed model accurately represents the original mixed-integer nonlinear model, obtaining a globally optimal solution in less computational time with low errors. The mathematical model allows for considering constraints related to the maximum limits for the penetration of distributed generation, such as those specified by Resolution CREG 174 of 2021. Furthermore, the uncertainties of the electrical demand, wind energy-based distributed generation (DG), and solar energy-based DG are considered in the mathematical models using a two-stage stochastic programming approach. The accuracy and efficiency of the proposed model were tested and validated on a 21-node DC test system from the specialized literature, and the effectiveness and robustness were assessed on a 69-node DC test system. The obtained results show that the proposed stochastic mixed-integer linear mathematical model performs well.