Food handlers and consumers are responsible for avoiding foodborne diseases (FBD). Considering the meals consumed away from home, can the consumer identify the FBD risk level of the food that he/she consumes in restaurants? This study aimed to evaluate the knowledge, risk perception, and optimistic bias of food handlers and consumers of restaurants and the relationship of these variables with the FBD risk of these establishments. Sixty-four handlers and 265 consumers of 14 restaurants in the city of Limeira - São Paulo, Brazil participated in the study. A validated checklist was used to evaluate the food safety profile of restaurants with a score ranging from zero to 2565.95. A structured questionnaire was employed to assess knowledge of food safety and the risk perception of FBD. The food handlers indicated their own risk and their peers' risk of causing a FBD. Consumers evaluated their own risk and the risk of their peers of contracting a FBD after making their own meals, consuming meals at the studied restaurants and consuming meals in other food establishments. The answers were based on a structured scale with seven options. The difference between their risk perception levels (risk attributed to itself and to a peer) indicated the optimistic bias of FBD risk. The mean food safety risk score of the food service establishments was 105.51. The restaurants were classified into two groups, higher or lower FBD risk. The mean score of knowledge (percentage of correct answers) of food safety was 61.7% for handlers and 59% for consumers, showing a nonsignificant difference (p = .29). Both food handlers and consumers stated that they were less at risk for FBD than their peers (p < .001). A direct effect of consumers' optimistic bias on food service FBD risk was observed through multivariate analysis. Optimistic bias may lead consumers to choose restaurants with a higher FDB risk. A direct negative effect of food handlers' knowledge of food service FBD risk was observed. These results show that consumers may have incorporated a sense of affection and identity to a place, associating it with making their own meals at home. Therefore, the consumer may not differentiate restaurants with regard to food safety. This result reinforces the need for governments and health agencies to protect the health of the population. Copyright © 2019 Elsevier Ltd. All rights reserved.