The message There were undefined references is one of the last things printed on screen to catch your attention to the issue. However, scrolling up to the console output or the log file will show the line number where the undefined reference was found. The file
\documentclass{article}
\begin{document}
\section{foo}\label{foo}
This is section \ref{fo}
\end{document}
returns
LaTeX Warning: Reference `fo' on page 1 undefined on input line 4.
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./mwe.aux)
LaTeX Warning: There were undefined references.
Of course, if after the undefined reference there are many pages, possibly with figures, you might have to scroll back a lot.
If you \input external files then you must keep in mind that the quoted line number always refers to the current file. Assume that we have a file foo.tex
\section{foo}\label{foo}
This is section \ref{fo}
and the main file main.tex reads
\documentclass{article}
\begin{document}
Text text.
\input{foo}
\end{document}
then the log will contain
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/TeX Live for SUSE Linux) (preloaded format=pdflatex 2019.9.25) 9 APR 2021 14:59
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**main.tex
(./main.tex
LaTeX2e <2017-04-15>
% [ ... other stuff ... ]
(./foo.tex
LaTeX Warning: Reference `fo' on page 1 undefined on input line 2.
) [1
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./mwe.aux)
LaTeX Warning: There were undefined references.
)
% [ ... other stuff ...]
Here the line number refers to the external file: watch out for the string (./foo.tex which means that this is the currently open file. The corresponding closing parenthesis ) is shown just after the warning; the final closing parenthesis refers to the main file (the corresponding opening one is on the 6th line).
Reference XXX on page XXX undefined on input line XXX. – campa Apr 09 '21 at 12:42