N-nitrosodimethylamine (NDMA) and N-nitrosodiethylamine (NDEA), group 2A carcinogens, were detected in finished drug products, including metformin, ranitidine, sartans and other drugs which caused multiple recalls in the USA and Europe. Important studies also reported the formation of NDMA when ranitidine and nitrite were added to simulated gastric fluid. Our objective was to screen finished drug products from Europe and USA for nitrosamine impurities and investigate the formation of NDMA in metformin finished drug products when added to simulated gastric fluid. One dosage unit of 30 different commercially available drugs, including metformin, sartans, and ranitidine were tested for NDMA, NDEA, and dimethylformamide (DMF) impurities, using a liquid chromatography-mass spectrometry (LC–MS) method. Then, 6 metformin finished drug products were tested in stomach conditions for 2 h at 37 °C in a 100 mL solution with a pH of 2.5 and different nitrite concentrations (40, 10, 1, 0.1 mM) and tested for NDMA, and DMF using LC–MS. We measured NDMA, NDEA, and DMF in 30 finished drug products. NDMA and DMF were quantified for metformin drug products in simulated gastric fluid with different nitrite concentrations. None of the 30 drugs showed concerning levels of NDMA, NDEA, or DMF when tested as single tablets. However, when metformin tablets are added to simulated gastric fluid solutions with high nitrite concentrations (40 mM and 10 mM), NDMA can reach amounts of thousands of nanograms per tablet. At the closest concentration to physiologic conditions we used, 1 mM, NDMA is still present in the hundreds of nanograms in some metformin products. In this in vitro study, nitrite concentration had a very important effect on NDMA quantification in metformin tablets added to simulated gastric fluid. 1 mM nitrite caused an increase above the acceptable daily intake set by the U.S. Food and Drug Administration (FDA) for some of the metformin drugs. 10 mM, 40 mM nitrite solutions generated NDMA amounts exceeding by more than a hundred times the acceptable daily intake set by the FDA of 96 nanograms. These findings suggest that metformin can react with nitrite in gastric-like conditions and generate NDMA. Thus, patients taking metformin could be exposed to NDMA when high nitrite levels are present in their stomach, and we recommend including a statement within the Patient Package Inserts/Instructions for use.