Bookstack API 30 Second Timeout with PDF Export #5298

Closed
opened 2026-02-05 09:56:01 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @TheLH1 on GitHub (May 29, 2025).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hello,

I have a PowerShell script which exports the bookstack books as PDF, Markdown and HTML. While Markdown and HTML work fine, some books reach an export limit of 30 seconds. I have already tried changing the export time in the .env file. But this seems to not affect the export time.

Sometimes, some books when exporting as PDF give the following error:

{ "error": { "message": "Maximum execution time of 30 seconds exceeded", "code": 500 } }

This is the following PowerShell test code I used. When selecting the book with the export issue it would still not export, I tried this with a book that I know can export fine and it worked as usual.

`$apiBaseUrl = "https://wiki.company.co.uk/api" 
$apiTokenId = "Redacted"
$apiTokenSecret = "Redacted"

$headers = @{
    "Authorization" = "Token $($apiTokenId):$($apiTokenSecret)"
}

$exportUrl = "$apiBaseUrl/books/27/export/pdf"

Invoke-WebRequest -Uri $exportUrl -Headers $headers -OutFile "C:\temp\test.pdf"`

I am unsure if I am just being a noob, or if there is a setting somewhere that I am missing. Any pointers would be much appreciated. For reference the file size from when the PDF last successfully exported was 2,179kb.

Exact BookStack Version

v25.02.5

Log Content

No response

Hosting Environment

We are hosting bookstack in an internal environment on a Virtual Linux server.

Originally created by @TheLH1 on GitHub (May 29, 2025). ### Attempted Debugging - [x] I have read the debugging page ### Searched GitHub Issues - [x] I have searched GitHub for the issue. ### Describe the Scenario Hello, I have a PowerShell script which exports the bookstack books as PDF, Markdown and HTML. While Markdown and HTML work fine, some books reach an export limit of 30 seconds. I have already tried changing the export time in the .env file. But this seems to not affect the export time. Sometimes, some books when exporting as PDF give the following error: `{ "error": { "message": "Maximum execution time of 30 seconds exceeded", "code": 500 } }` This is the following PowerShell test code I used. When selecting the book with the export issue it would still not export, I tried this with a book that I know can export fine and it worked as usual. ``` `$apiBaseUrl = "https://wiki.company.co.uk/api" $apiTokenId = "Redacted" $apiTokenSecret = "Redacted" $headers = @{ "Authorization" = "Token $($apiTokenId):$($apiTokenSecret)" } $exportUrl = "$apiBaseUrl/books/27/export/pdf" Invoke-WebRequest -Uri $exportUrl -Headers $headers -OutFile "C:\temp\test.pdf"` ``` I am unsure if I am just being a noob, or if there is a setting somewhere that I am missing. Any pointers would be much appreciated. For reference the file size from when the PDF last successfully exported was 2,179kb. ### Exact BookStack Version v25.02.5 ### Log Content _No response_ ### Hosting Environment We are hosting bookstack in an internal environment on a Virtual Linux server.
OVERLORD added the 🐕 Support label 2026-02-05 09:56:01 +03:00
Author
Owner

@ssddanbrown commented on GitHub (May 29, 2025):

Hi @TheLH1,

Do you have a EXPORT_PDF_COMMAND or WKHTMLTOPDF or EXPORT_PDF_COMMAND_TIMEOUT option set within your configured BookStack env options? If so, please confirm their values.

@ssddanbrown commented on GitHub (May 29, 2025): Hi @TheLH1, Do you have a `EXPORT_PDF_COMMAND` or `WKHTMLTOPDF` or `EXPORT_PDF_COMMAND_TIMEOUT` option set within your configured BookStack env options? If so, please confirm their values.
Author
Owner

@TheLH1 commented on GitHub (May 29, 2025):

Hi @ssddanbrown,

Thanks for the reply!

I do not have the EXPORT_PDF_COMMAND set or WKHTMLTOPDF set. But I do have the EXPORT_PDF_COMMAND_TIMEOUT set to 120 in the .env file. I timed this during testing and it does indeed time out after 30 seconds. Are there any additional recommended settings I am missing? Thank you.

@TheLH1 commented on GitHub (May 29, 2025): Hi @ssddanbrown, Thanks for the reply! I do not have the ` EXPORT_PDF_COMMAND` set or `WKHTMLTOPDF` set. But I do have the `EXPORT_PDF_COMMAND_TIMEOUT` set to 120 in the .env file. I timed this during testing and it does indeed time out after 30 seconds. Are there any additional recommended settings I am missing? Thank you.
Author
Owner

@ssddanbrown commented on GitHub (May 29, 2025):

Hi @TheLH1,

The EXPORT_PDF_COMMAND_TIMEOUT won't affect your current means of export since that's only relevant for the EXPORT_PDF_COMMAND option.

You could be hitting your php max_execution_time limit, which is 30 seconds by default.
This is usually configured via a php.ini file. This should be a variable already existing in the file, just needs to be changed.
Make sure you edit the right one though for your PHP version and the way you're running php. This can be different depending on OS, web-server and how you're running PHP via that web-server.
You may need to restart the webserver (and php process if using something like php-fpm) after making changes to the php.ini file.

@ssddanbrown commented on GitHub (May 29, 2025): Hi @TheLH1, The `EXPORT_PDF_COMMAND_TIMEOUT` won't affect your current means of export since that's only relevant for the `EXPORT_PDF_COMMAND` option. You could be hitting your php `max_execution_time` limit, which is 30 seconds by default. This is usually configured via a `php.ini` file. This should be a variable already existing in the file, just needs to be changed. Make sure you edit the right one though for your PHP version and the way you're running php. This can be different depending on OS, web-server and how you're running PHP via that web-server. You may need to restart the webserver (and php process if using something like `php-fpm`) after making changes to the `php.ini` file.
Author
Owner

@TheLH1 commented on GitHub (May 29, 2025):

Hi @ssddanbrown

This worked. Thanks a lot for the pointers! Legend!

@TheLH1 commented on GitHub (May 29, 2025): Hi @ssddanbrown This worked. Thanks a lot for the pointers! Legend!
Author
Owner

@boscorelly commented on GitHub (Sep 15, 2025):

Hi,
is it possible to set those env settings with docker ?

@boscorelly commented on GitHub (Sep 15, 2025): Hi, is it possible to set those env settings with docker ?
Author
Owner

@boscorelly commented on GitHub (Sep 15, 2025):

i was able to set i in /config/php/php-local.ini, but now i have a nginx timeout error

@boscorelly commented on GitHub (Sep 15, 2025): i was able to set i in /config/php/php-local.ini, but now i have a nginx timeout error
Author
Owner

@boscorelly commented on GitHub (Sep 15, 2025):

fixed : i had a 15MB file to generate, containing 221 pdf pages
Here are my settings.

config/php/php-local.ini :

upload_max_filesize = 100M
post_max_size = 100M

max_execution_time = 300
memory_limit = 512M

config/php/www2.conf :

; Pool name
[www]

request_terminate_timeout = 500

in config/nginx/site-confs/default.conf, added in inside location ~ ^(.+\.php)(.*)$ { block :
fastcgi_read_timeout 500;

@boscorelly commented on GitHub (Sep 15, 2025): fixed : i had a 15MB file to generate, containing 221 pdf pages Here are my settings. config/php/php-local.ini : ``` upload_max_filesize = 100M post_max_size = 100M max_execution_time = 300 memory_limit = 512M ``` config/php/www2.conf : ``` ; Pool name [www] request_terminate_timeout = 500 ``` in config/nginx/site-confs/default.conf, added in inside `location ~ ^(.+\.php)(.*)$ {` block : `fastcgi_read_timeout 500;`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5298