The increasing number of renewable energy sources (RESs) connected to power grids contributes to the emergence of not only balancing problems but also technical ones, such as the overloading of power lines. If renewable sources with a high generation level are planned to be connected in the area under consideration, then a large number of significant overloads should be expected, especially during contingency analysis. As a rule, high-voltage networks have a mesh topology, which is why the concept of using advanced mathematical algorithms was developed, with the help of which the resulting threats can be eliminated. This article presents a proposal for a new method of eliminating line overloads and determining the currently available nodal generation levels. Its innovation is a new method of eliminating problems related to the capacity of power grids. The high efficiency of the method results from the appropriately defined response of properly selected RES sources to the state of network congestion. The problem under consideration is illustrated with the example of a modified IEEE 118-bus test network. In order to eliminate line overloads, the article proposes a two-stage approach. In the first step, the sources that are most responsible for the occurring overloads are determined. In the second step, a metaheuristic algorithm is used to solve a nonlinear optimisation problem with constraints. This task involves reducing the power generated in the sources selected in the previous step in such a way that the resulting line overloads are eliminated, and, at the same time, the total value of the curtailed generation is minimal.