2D and 3D transonic flows in a channel of variable cross-section are studied numerically using a solver based on the Reynolds-averaged Navier–Stokes equations. The flow velocity is supersonic at the inlet and outlet of the channel. Between the supersonic regions, there is a local subsonic region whose upstream boundary is a shock wave, whereas the downstream boundary is a sonic surface. The sonic surface gives rise to an instability of the shock wave position in the channel. Computations reveal a hysteresis in the shock position versus the inflow Mach number. A dependence of the hysteresis on the velocity profile given at the inlet is examined.