2-Cyanobenzofurans and 2-cyanobenzothiophenes were prepared through an efficient one-pot Ullmann-reaction/cyanation reaction. In the presence of CuI/Na2CO3–Pd(OAc)2/PPh3 in DMF, the reaction of 2-(gem-dibromovinyl)phenols and 2-(gem-dibromovinyl)thiophenols with K4Fe(CN)6, as non-toxic and user-friendly cyanating reagent, proceeded smoothly to generate the corresponding 2-cyanobenzofurans and 2-cyanobenzothiophenes in good yields.