On the Gorenstein property of local models for
GLnLocal models, defined by linear algebra and explicit matrix equations, model étale-locally the singularities of integral models of Shimura varieties. This paper determines exactly which local models for $\mathrm{GL}_n$ are Gorenstein. This yields the analogous information for integral models of Shimura varieties for unramified unitary groups with parahoric level structure, and conversely produces certain natural matrix equations that define non-Gorenstein singularities.