A search for a heavy right-handed W boson (W-R) decaying to a heavy right-handed neutrino and a charged lepton in events with two same-flavor leptons (e or mu) and two jets, is presented. The analysis is based on proton-proton collision data, collected by the CMS Collaboration at the LHC in 2016 and corresponding to an integrated luminosity of 35.9 fb(-1). No significant excess above the standard model expectation is seen in the invariant mass distribution of the dilepton plus dijet system. Assuming that couplings are identical to those of the standard model, and that only one heavy neutrino flavor N-R contributes significantly to the W-R decay width, the region in the two-dimensional (m(WR), m(NR)) mass plane excluded at 95% confidence level extends to approximately m(WR) = 4 : 4TeV and covers a large range of right-handed neutrino masses below the W-R boson mass. This analysis provides the most stringent limits on the W-R mass to date.