Beans are one of the most important legumes for human consumption. However, its cultivation in soil contaminated with metal(loid)s may harm the human food chain. We aimed to investigate the accumulation and transfer of macro- and microelements from the soil to cowpea grains. In addition, soil pollution rates and health risks associated with grain consumption were assessed. Soil and grain samples were collected from plantations close to a landfill and a highway in the city of Campo Grande, Central-West Brazil. The quantification of As, Cd, Cr, Cu, Fe, Mg, Mn, Mo, Pb, Se, V, and Zn in the bean grain and soil samples of cowpea cultivation was carried out by Inductively Coupled Plasma Optical Emission Spectroscopy (ICP-OES). The pollution index, bioaccumulation coefficient, estimated daily intake, carcinogenic and non-carcinogenic risk were calculated. The concentration of Cd (0.052 +/- 0.001-0.069 +/- 0.008 mg/100 g) and Pb (0.136 +/- 0.019-0.216 +/- 0.054 mg/100 g) in grains was above the maximum permissible daily oral dose. In addition, the hazard quotients (HQ) of the elements As, Cd, Pb, Se, and V were above the safety limit, surpassing HQ of 10 for As and Cd at all collection sites and the hazard index was greater than 27 for all sampling locations. The heavy metals As, Cd, and Cr present elevated carcinogenic risk (CRi), above 1.6 x 10-3 for cowpea intake of all studied locations. The proximity of the cowpea crop to the highway and the landfill contributed to the contamination of the soil and grains. These findings highlight the importance of monitoring and understanding the soil-plant-human system, especially when the environmental conditions surrounding crops are favorable to contamination, representing a major risk to public health.