—This article presents a novel algorithm for optimal planning of a dispatchable distributed generator connected to the distribution networks. The proposed algorithm modifies the traditional firefly method to be able to deal with the practically constrained optimization problems by proposing formulas for tuning the algorithm parameters and updating equations. The proposed algorithm rigidly determines the optimal location and size of the distributed generation units in order to minimize the system power loss without violating the system practical constraints. Moreover, the optimal distributed generator location and minimum size for achieving a certain specified power loss are determined using the proposed method and compared to the results of a proposed heuristic technique. The distributed generation units in the proposed algorithms are modeled as voltage controlled nodes with the flexibility to be converted to constant power nodes in the case of reactive power limit violation. The proposed algorithms are implemented in MATLAB and tested on the IEEE 33-bus and the IEEE 37-nodes feeder. The results that are via comparison with published results obtained from other competing methods show the effectiveness, accuracy, and speed of the proposed method.