This paper studies an optimal insurance problem for a utility-maximizing buyer of insurance, subject to the seller's endogenous default and background risk. An endogenous default occurs when the buyer's contractual indemnity exceeds the seller's available reserve, which is random due to the background risk. We obtain an analytical solution to the optimal contract for two types of contracts, differentiated by whether their indemnity functions depend on the seller's background risk. The results sh...