We develop a theory of "risky utilities," i.e., private firms that manage an infrastructure for public service and that may be tempted to engage in excessively risky activities, such as reducing maintenance expenditures (at the risk of provoking a breakdown of the system) or in speculation (at the risk of incurring massive losses it cannot bear). These risky utilities include financial utilities like exchanges, clearinghouses or payment systems, as well as standard utilities like electricity transmission networks. Continuation of service is essential, so risky utilities cannot be liquidated. The optimal regulatory contract minimizes the social cost among the contracts that steer the firm away from risky activities. It is simple and implemented with a capital (equity) adequacy requirement and a resolution mechanism when that requirement is breached. The social cost function is explicitly computed, and comparative statics can be simply derived.