Koha Solutions

Installation & setup

Koha cannot locate the configuration file koha-conf.xml

The error means the process has no KOHA_CONF set, not that the file is gone. Run the command through koha-shell, and here is how to confirm the file really is where Koha expects it.

Updated 2026-08-12 · Tested against Koha 26.05

Nine times out of ten the file is exactly where it should be and the shell you ran the command in has no KOHA_CONF — Koha finds its configuration only through that variable. Run the command through sudo koha-shell <instance>, which sets it for you, and the error disappears without changing anything on disk.

What the error looks like

Terminal
perl /usr/share/koha/bin/some-script.pl CAUTION: Can't find koha-conf.xmlunable to locate Koha configuration file koha-conf.xml

It often arrives with a second, less helpful line — Can't call method "config" on an unblessed reference. That is the same fault one step later: the configuration object was never built, so the next line of Perl calls a method on nothing.

Step 1Get the instance name right

Terminal
sudo koha-list library

Every instance is a directory under /etc/koha/sites/, and koha-list prints the ones that exist. Use that exact string below — koha, Koha and the library's name are the three things people guess, and none of them is it unless koha-list says so.

Step 2Run the command through koha-shell

Terminal
sudo koha-shell libraryperl /usr/share/koha/bin/some-script.pl

Replace library with your instance name. koha-shell drops you into a shell owned by that instance's system user with KOHA_CONF and PERL5LIB already exported, which is the supported way to run anything by hand. To run a single command without staying in the shell, use -c:

Terminal
sudo koha-shell -c "perl /usr/share/koha/bin/some-script.pl" library

Or set the variable yourself

In a script that cannot call koha-shell — a systemd unit, someone else's wrapper — export the path directly. Nothing else reads it, so this is the whole fix:

Terminal
export KOHA_CONF=/etc/koha/sites/library/koha-conf.xmlexport PERL5LIB=/usr/share/koha/lib

Check whether the file really is missing

If the two steps above did not help, confirm the file exists before assuming anything else:

Terminal
sudo ls -l /etc/koha/sites/library/koha-conf.xml -rw-r----- 1 library-koha library-koha 24596 Aug  9 11:02 /etc/koha/sites/library/koha-conf.xml

Note the ownership. The file is readable by the instance user and by root, and by nobody else — so the same command that works under sudo fails as an ordinary user with exactly this error, because Perl cannot open a file it is not allowed to read. That is the second most common cause after the unset variable.

If the file is genuinely not there, do not write a new one by hand

It carries the database password, the Zebra ports, the memcached prefix and the instance's own paths, all generated when the instance was created. A hand-written replacement will start Koha and then fail in ways that look like data corruption.
  • Restore it from your backup — koha-dump archives the configuration alongside the database.
  • If there is no backup and no instance, the instance was never created: run koha-create rather than repairing.

Why this happens

Koha has no compiled-in configuration path. Every process discovers its instance from the KOHA_CONF environment variable, and that is deliberate: it is what lets one server run twenty instances from one copy of the code, each with its own database, ports and paths.

Each place Koha runs sets the variable in its own way. Apache sets it per virtual host — the site file contains SetEnv KOHA_CONF "/etc/koha/sites/library/koha-conf.xml" in both the OPAC and the staff blocks, which is why the web interface works perfectly while a command in a terminal does not. The scheduled jobs get it from koha-foreach. A root shell gets it from nowhere at all.

So the error is almost never about a missing file. It is a command being run outside the only three contexts that were ever arranged to set the variable, and koha-shell exists precisely to be a fourth.

Troubleshooting

What you seeWhat it usually is
The web interface works, a shell command does notThe classic case. Apache sets KOHA_CONF per virtual host; your shell does not. Use koha-shell.
Works under <code>sudo</code>, fails as your own userFile permissions, not configuration. koha-conf.xml is readable only by the instance user and root.
Fails for one instance and works for anotherThe instance name in the path is wrong. Check it against sudo koha-list.
<code>Can't call method "config" on an unblessed reference</code>The same fault one line later — the config was never loaded. Fix the variable, not the Perl.
A cron job fails but the same command works by handcron has almost no environment. Wrap the job in koha-foreach or koha-shell -c.
The web installer cannot get past the database stepA different problem — the database credentials, not the config path. See finding your instance's admin password.

If the staff interface itself is not answering rather than a script failing, the cause is on the Apache side instead — start with Koha, Apache and port 8080.

Share this article

Would rather not do this yourself? We do it as a service — and if you would rather it were already done, it is on Koha Cloud before you log in.