On-line control and optimization can improve the eﬃciency of fuel cell systems whilst simultaneously ensuring that the operation remains within a safe region. Also, fuel cells are subject to frequent variations in their power demand. This paper investigates the real-time optimization (RTO) of a solid oxide fuel cell (SOFC) stack. An optimization problem maximizing the efficiency subject to operating constraints is deﬁned. Due to inevitable model inaccuracies, the open-loop implementation of optimal inputs evaluated oﬀ-line may be suboptimal, or worse, infeasible. Infeasibility can be avoided by controlling the constrained quantities. However, the constraints that determine optimal operation might switch with varying power demand, thus requiring a change in the regulator structure.