CU Vir has been the first main sequence star that showed regular radio pulses that persist for decades, resembling the radio lighthouse of pulsars and interpreted as auroral radio emission similar to that found in planets. The star belongs to a rare group of magnetic chemically peculiar stars with variable rotational period. We study the ultraviolet (UV) spectrum of CU Vir obtained using STIS spectrograph onboard the Hubble Space Telescope (HST) to search for the source of radio emission and to test the model of the rotational period evolution. We used our own far-UV and visual photometric observations supplemented with the archival data to improve the parameters of the quasisinusoidal long-term variations of the rotational period. We predict the flux variations of CU Vir from surface abundance maps and compare these variations with UV flux distribution. We searched for wind, auroral, and interstellar lines in the spectra. The UV and visual light curves display the same long-term period variations supporting their common origin. New updated abundance maps provide better agreement with the observed flux distribution. The upper limit of the wind mass-loss rate is about 10^-12^M_{sun}_/yr. We do not find any auroral lines. We find rotationally modulated variability of interstellar lines, which is most likely of instrumental origin. Our analysis supports the flux redistribution from far-UV to near-UV and visual domains originating in surface abundance spots as the main cause of the flux variability in chemically peculiar stars. Therefore, UV and optical variations are related and the structures leading to these variations are rigidly confined to the stellar surface. The radio emission of CU Vir is most likely powered by a very weak presumably purely metallic wind, which leaves no imprint in spectra.