The near-resonant flow of a stratified fluid through a localized contraction is considered in the long-wavelength weakly nonlinear limit to investigate the transient development of nonlinear internal waves and whether these might lead to local steady hydraulic flows. It is shown that under these circumstances the response of the fluid will fall into one of three categories, the first governed by a forced Korteweg—de Vries equation and the latter two by a variable-coefficient form of this equation. The variable-coefficient equation is discussed using analytical approximations and numerical solutions when the forcing is of the same (positive) and of opposite (negative) polarity to that of free solitary waves in the fluid. For positive and negative forcing, strong and weak resonant regimes will occur near the critical point. In these resonant regimes for positive forcing the flow becomes locally steady within the contraction, while for negative forcing it remains unsteady within the contraction. The boundaries of these resonant regimes are identified in the limits of long and short contractions, and for a number of common stratifications.