Introduction: Whether good baseline quality of life (QOL) is linked to improved QOL: improved overall survival (OS) which is relevant to HLA-restricted peptides has not been evaluated, and the causal nature of this correlation is not known. Methods: Pretreatment patient-reported QOL using the QOL-20 questionnaire and blood human leukocyte antigens (HLAs) was examined in 437 and 325 gastric cancer (GC) patients, respectively. We focused on the similarity between human endogenous retrovirus (HERV) and human immunodeficiency virus (HIV) genes, and HLA-restricted CD8 + cytotoxic T-lymphocyte epitopes on HERV and HIV genes were predicted using bioinformatics. We focused on loneliness/sleep of QOL-20, and QOL-relevant HLA-restricted HERV gene derived-peptides (QOL-relevant HERV peptides) were selected based on the similarity of HLA-restricted HIV peptides and assessed the association between these factors and OS. Results: Some items (state of health, appetite, suffocation, and sleep) have been identified as prognostic factors in patients with GC. The benefits of harboring QOL-relevant HERV peptides were seen in the positive category responders who responded to the positive category in each item, except for the worries item. Among responders to the loneliness item who had QOL-relevant HERV peptides, male positive category responders and female negative category responders who responded to negative category harboring HLA-A31 showed significantly better outcomes than the other groups (log-rank test, P = 0.016 and P = 0.043, respectively). Positive category responders ≤ 64 years old harboring HLA-A11 and negative category responders harboring HLA-A33 showed significantly better outcomes than the other groups (log-rank test, P = 0.048 and P = 0.024, respectively). Conclusions: Our research on QOL relevant-HERV peptides will facilitate the development of more precise personalized medicine for cancer treatment.