LibreOffice fails to start in Gotenberg
Gotenberg starts LibreOffice when it needs it and gives it 20 seconds to be ready. On a slow or busy machine, a NAS or a container short of memory, LibreOffice can take longer, and Gotenberg reports that it did not start. Give it longer with --libreoffice-start-timeout, start it with the container, and give the container more memory.
Gotenberg 8.34 to 8.40:
LibreOffice did not become available within the start timeout; increase --libreoffice-start-timeout or check system resources: context deadline exceededGotenberg 7.10 to 8.33:
LibreOffice socket not available: context deadline exceededGotenberg 7:
start long-running LibreOffice listener: execute LibreOffice listener: context done: context deadline exceededThe app that sent the document usually sees 503 Service Unavailable.
Twenty seconds to start.
- The start takes longer than the start timeout.
--libreoffice-start-timeout, 20 seconds by default, bounds each start and each restart. Weak processors, NAS boxes and containers starting from cold can take longer. - LibreOffice starts inside a request. Unless told to start with the container, it starts with the first Office document, and again after every 10 conversions; a slow start then fails that request too.
- Not enough memory or CPU. A container short of memory, with Chromium beside LibreOffice, can have its LibreOffice stopped as it starts.
- Old versions and hosts. Some older Gotenberg images carried LibreOffice builds that started unreliably; Gotenberg 8.27 to 8.31 also kept failing after one failed start until the container was restarted (fixed in 8.32). Gotenberg’s documentation asks Debian hosts to run a current version of Debian.
A longer start, at start-up.
1. Give LibreOffice longer to start, and start it with the container. In your compose file, add these lines to the gotenberg service:
gotenberg:
image: gotenberg/gotenberg:8
+ command:
+ - "gotenberg"
+ - "--libreoffice-start-timeout=60s"
+ - "--libreoffice-auto-start=true"
+ - "--api-timeout=120s"
If the service has a command already, as Paperless-ngx’s has, add only the three lines that start with --. The longer --api-timeout leaves room for a start inside a request. From Gotenberg 8.17 the same settings also work as environment variables: LIBREOFFICE_START_TIMEOUT, LIBREOFFICE_AUTO_START and API_TIMEOUT.
2. Start the service again, and wait until it reports LibreOffice up. The second command asks the server’s health from inside its container, so it works whether or not the service publishes a port:
docker compose up -ddocker compose exec gotenberg curl --fail --silent --retry 30 --retry-delay 2 --retry-all-errors http://localhost:3000/health3. If it still fails, give the container more memory and CPU, and run the latest Gotenberg 8 image or Gotenberg 9. On a Synology NAS with Paperless-ngx, Gotenberg’s documentation points to a configuration users tested at length: more memory, a longer start timeout and API timeout, LibreOffice started with the container and never restarted.
Nothing to start.
Marqius Kern answers Gotenberg’s API and reads Word, Excel and PowerPoint files itself, with no LibreOffice inside, so there is no office suite to start, time or restart. It is ready in 0.14 seconds, and the first document converts like the hundredth.
In our test, a container given a fiftieth of a processor, as a slow machine gives it: Gotenberg 8 with its defaults answered the first Word file with 503 after 20 seconds, LibreOffice not started; with the fix above, LibreOffice was up after 37 seconds and the file converted. Marqius Kern converted it in under half a second.
The switch is the image line, then the same command:
- image: gotenberg/gotenberg:8
+ image: marqius/kern
docker compose up -dIt takes the same flags, --libreoffice-start-timeout among them, which then has nothing to wait for. It reads Word, Excel, PowerPoint, OpenDocument, RTF and CSV files; rarer formats, such as PowerPoint 97-2003, OpenDocument drawings and Visio, are refused with the reason.
Free for open source. Licensed for business.
Personal, teaching and open-source use is free with a Community licence, including open-source projects’ CI runs and documentation builds.
- Get your free key on marqius.com/licence/marqius-kern, then sign in with Google.
- Tick “I’ll use Marqius Kern only for personal, teaching or open-source work”.
- Get my free key, then Copy key.
- Set it as the variable
MARQIUS_LICENCEon your server.
Anything done by or for a business, including internal tools and client work, needs a paid licence. See the plans and prices.
Questions
What does “LibreOffice listener fails to start” mean?
Gotenberg started LibreOffice to convert an Office file, and LibreOffice was not ready within the start timeout. Gotenberg 7 called LibreOffice’s connection a listener, 8 a socket; Gotenberg 8.34 and later say “did not become available within the start timeout”.
What is Gotenberg’s LibreOffice start timeout?
20 seconds, set by --libreoffice-start-timeout (LIBREOFFICE_START_TIMEOUT from Gotenberg 8.17). It bounds every start and restart of LibreOffice.
Why does it fail on a Synology NAS or a Raspberry Pi?
A slower processor and less memory make LibreOffice’s start longer than 20 seconds. Raise --libreoffice-start-timeout and --api-timeout, start LibreOffice with the container, and give the container more memory.
Does --libreoffice-auto-start help?
Yes: LibreOffice then starts with the container, not inside the first request, so that request does not wait for it.
Does Marqius Kern need LibreOffice?
No. It reads Word, Excel, PowerPoint, OpenDocument, RTF and CSV files itself, so there is nothing to start: it is ready in 0.14 seconds.
Change one line. Keep your documents.
Compare your own documents side by side first, as the switching guide shows, then switch.