The optimal bandwidth selection in kernel-based nonparametric density estimation is one of the important parts in the spectral density estimation under long-range dependence (LRD). To improve the performance of the nonparametric spectral density estimation (NPSDE) under LRD, we propose a new cosine-based variable bandwidth selection method, which is motivated by variable bandwidth selection for density estimation and spectral density for autoregressive fractionally-integrated moving average models. The performance of the proposed method was illustrated through the simulation studies and data examples. The proposed cosine-based variable bandwidth selection method for NPSDE under LRD provides better performance than any other bandwidth selection method. Our method is robust to any values of the fractional differencing parameters.