LaTeX error "I couldn't open database file references.bib": cause and fix
BibTeX did not find the .bib file named in \bibliography{...}. The message is in the BibTeX log, the .blg file. In the LaTeX log you only see the consequence: every citation is undefined.
Why it happens
- The name in
\bibliography{...}differs from the file name, for examplereferenceswhen the file isrefs.bib. - The
.bibfile lies in a subfolder and the command gives only the name. - The
.bibfile is not part of the project.
How to fix it
- Write the file name without
.bibin\bibliography{refs}and compare it with the file, letter by letter. - Give the path from the main document:
\bibliography{literature/refs}. - After the fix, run BibTeX again and then LaTeX twice.
A document that produces the message
\documentclass{article}
\begin{document}
The algorithm is described in \cite{knuth1984}.
\bibliographystyle{plain}
\bibliography{references}
\end{document}File refs.bib:
@book{knuth1984,
author = {Donald E. Knuth},
title = {The TeXbook},
publisher = {Addison-Wesley},
year = {1984}
}Tools run in this order: pdflatex → bibtex.
The corrected document
\documentclass{article}
\begin{document}
The algorithm is described in \cite{knuth1984}.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.