Primary liver cancer (PLC) is the sixth most frequently occurring cancer, representing one of the top 5 leading causes of cancer-related mortality worldwide. Recently, researchers have focused more on the impact of living habits on the incidence and development of tumours. This study reports a relationship between sleep traits and PLC.In this study, we used published genome-wide association studies to obtain exposure factors of 6 sleep traits. Mendelian randomization (MR) analysis was used to assess the causal relationship between sleep traits and PLC via inverse-variance weighted (IVW), MR Egger and weighted median. Sensitivity analysis was used to reduce the bias.Our investigation revealed that there was a negative correlation between sleep duration and the group of liver and bile duct cancer by IVW (p-value = .042), and this result was similarly observed in the liver cell carcinoma group by Weighted Median (p-value = .026). In contrast, there was a positive correlation found between napping during the day and primary liver cancer in the cohorts of liver and bile duct cancer (p-value = .030), liver cell carcinoma (p-value = .043) and malignant neoplasm of other and unspecified parts of the biliary tract (p-value = .016) by IVW. Furthermore, our study also revealed a positive correlation between insomnia and malignant neoplasm of the liver and intrahepatic bile ducts by IVW (p-value = .022).Overall, our study indicates that insomnia and nap during the day may be risk factors of PLC and adequate night sleep might keep us away from PLC.