The answer to the question fancyhdr - Change horizontal line color on top of footer is not completely satisfactory, because it changes the position of the header line, for example with this example.
\documentclass{article}
\usepackage{xcolor}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\headrule}{\hbox to\headwidth{\color{red}\leaders\hrule height \headrulewidth\hfill}}
\fancyhead[LE,RO]{Hello}
\pagestyle{fancy}
\begin{document}
hello
\end{document}
Is it possible to change only the color of the line, without changing its position?
\renewcommand{\headrule}{{\color{red}\rule{\textwidth}{0.5pt}}}
should do the trick. – Bernard Mar 14 '19 at 18:33