This paper provides a theoretical framework to quantitatively investigate the optimal accumulation of international reserves to hedge against rollover risk. We study a dynamic model of endogenous default in which the government faces a tradeoff between the insurance benefits of reserves with the cost of keeping larger gross debt positions. A calibrated version of our model is able to rationalize large holdings of international reserves, as well as the procyclicality of reserves and gross debt positions. Model simulations are also consistent with spread dynamics and other key macroeconomic variables in emerging economies. The benefits of insurance arrangements and the effects of restricting the use of reserves after default are also analyzed.