The effects of ketoconazole, an inhibitor of corticosterone synthesis, were examined during food satiation and food restriction in male and female rats to determine whether increases in heroin self-administration prompted by food restriction were due to a stress response. Females self-administered more heroin infusions than males under both feeding conditions. Food restriction increased heroin infusions by an average of 96% for both females and males. Ketoconazole suppressed the increase due to food restriction in females but not in males. Corticosterone reversed the effect of ketoconazole in a group of 8 females, suggesting an interaction between feeding conditions, sex, and the stress response in rats.