[GH-ISSUE #2054] [Bug]: Encountering "Uncaught ErrorException: Cannot modify header information - headers already sent" #1084

Closed
opened 2026-02-26 02:35:11 +03:00 by kerem · 5 comments
Owner

Originally created by @lewislarsen on GitHub (Aug 17, 2025).
Original GitHub issue: https://github.com/koel/koel/issues/2054

Originally assigned to: @phanan on GitHub.

Read the Troubleshooting guide.

  • I have read and followed the Troubleshooting guide

Reproduction steps

  1. Configure Koel Docker Image 7.12.0 with Docker Compose.
  2. Run php artisan koel:init --no-assets
  3. Run php artisan koel:scan
  4. Attempt to play media in the browser

Expected behavior

The music to begin playing.

Actual behavior

The music did not play and an error presented in both the Browser Console and the Laravel logs.

Logs

Console:

23:04:02.205 GET
https://music.larsens.dev/play/9fa8889d-106b-4768-9749-f90996a689dc?t=4|wjo9JkG2uxlNtVysD2NXQXePlEK1AdNrqyTA4nw12c1e0857
NS_ERROR_NET_PARTIAL_TRANSFER

Laravel Logs:

2025-08-17 21:48:28] production.ERROR: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /var/www/html/vendor/symfony/http-foundation/Response.php:322
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():255}()
#2 /var/www/html/vendor/symfony/http-foundation/Response.php(322): header()
#3 /var/www/html/vendor/symfony/http-foundation/Response.php(401): Symfony\Component\HttpFoundation\Response->sendHeaders()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(219): Symfony\Component\HttpFoundation\Response->send()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(196): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse()
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()
#7 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():255}()
#8 {main}
  thrown {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /var/www/html/vendor/symfony/http-foundation/Response.php:322
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->{closure:Illuminate\\Foundation\\Bootstrap\\HandleExceptions::forwardsTo():255}()
#2 /var/www/html/vendor/symfony/http-foundation/Response.php(322): header()
#3 /var/www/html/vendor/symfony/http-foundation/Response.php(401): Symfony\\Component\\HttpFoundation\\Response->sendHeaders()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(219): Symfony\\Component\\HttpFoundation\\Response->send()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(196): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->renderHttpResponse()
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException()
#7 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->{closure:Illuminate\\Foundation\\Bootstrap\\HandleExceptions::forwardsTo():255}()
#8 {main}
  thrown at /var/www/html/vendor/symfony/http-foundation/Response.php:322)
[stacktrace]
#0 {main}
"}
root@af0812935eb0:/var/www/html#

Koel version

Koel v7.12.0 Community Edition

How did you install Koel?

Official Docker image

Additional information

  • Server OS: Ubuntu 24.04.3 LTS
  • PHP version: The version that comes bundled with the image.
  • Database: MariaDB 10.11.14
  • Node version: N/A (Prebuilt)
  • Browser & device: Firefox 141.0.3 (However this issue happens on Safari and Chrome too!)
  • Additional context:

I have configured FORCE_HTTPS=true as it was needed due to the subdomain having SSL.

The issue still happens even if I disable my reverse proxy, turn off FORCE_HTTPS and navigate to Koel with the IP and port combination.

When visiting the link (/play/blah-blah-blah etc) present in the browser console, I download an m4a that seems to play fine locally so I don't think it's an issue with how Koel is handling my FLAC files.

Originally created by @lewislarsen on GitHub (Aug 17, 2025). Original GitHub issue: https://github.com/koel/koel/issues/2054 Originally assigned to: @phanan on GitHub. ### Read the Troubleshooting guide. - [x] I have read and followed the Troubleshooting guide ### Reproduction steps 1. Configure Koel Docker Image 7.12.0 with Docker Compose. 2. Run `php artisan koel:init --no-assets` 3. Run `php artisan koel:scan` 4. Attempt to play media in the browser ### Expected behavior The music to begin playing. ### Actual behavior The music did not play and an error presented in both the Browser Console and the Laravel logs. ### Logs **Console:** ``` 23:04:02.205 GET https://music.larsens.dev/play/9fa8889d-106b-4768-9749-f90996a689dc?t=4|wjo9JkG2uxlNtVysD2NXQXePlEK1AdNrqyTA4nw12c1e0857 NS_ERROR_NET_PARTIAL_TRANSFER ``` Laravel Logs: ``` 2025-08-17 21:48:28] production.ERROR: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /var/www/html/vendor/symfony/http-foundation/Response.php:322 Stack trace: #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():255}() #2 /var/www/html/vendor/symfony/http-foundation/Response.php(322): header() #3 /var/www/html/vendor/symfony/http-foundation/Response.php(401): Symfony\Component\HttpFoundation\Response->sendHeaders() #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(219): Symfony\Component\HttpFoundation\Response->send() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(196): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException() #7 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():255}() #8 {main} thrown {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /var/www/html/vendor/symfony/http-foundation/Response.php:322 Stack trace: #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError() #1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->{closure:Illuminate\\Foundation\\Bootstrap\\HandleExceptions::forwardsTo():255}() #2 /var/www/html/vendor/symfony/http-foundation/Response.php(322): header() #3 /var/www/html/vendor/symfony/http-foundation/Response.php(401): Symfony\\Component\\HttpFoundation\\Response->sendHeaders() #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(219): Symfony\\Component\\HttpFoundation\\Response->send() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(196): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->renderHttpResponse() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException() #7 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->{closure:Illuminate\\Foundation\\Bootstrap\\HandleExceptions::forwardsTo():255}() #8 {main} thrown at /var/www/html/vendor/symfony/http-foundation/Response.php:322) [stacktrace] #0 {main} "} root@af0812935eb0:/var/www/html# ``` ### Koel version Koel v7.12.0 Community Edition ### How did you install Koel? Official Docker image ### Additional information - **Server OS**: Ubuntu 24.04.3 LTS - **PHP version**: The version that comes bundled with the image. - **Database**: MariaDB 10.11.14 - **Node version**: N/A (Prebuilt) - **Browser & device**: Firefox 141.0.3 (However this issue happens on Safari and Chrome too!) - **Additional context**: I have configured `FORCE_HTTPS=true` as it was needed due to the subdomain having SSL. The issue still happens even if I disable my reverse proxy, turn off FORCE_HTTPS and navigate to Koel with the IP and port combination. When visiting the link (/play/blah-blah-blah etc) present in the browser console, I download an m4a that seems to play fine locally so I don't think it's an issue with how Koel is handling my FLAC files.
kerem closed this issue 2026-02-26 02:35:11 +03:00
Author
Owner

@lewislarsen commented on GitHub (Aug 17, 2025):

Update two:

I just switched my Koel instance to use x-accel-redirect method and the PHP error I mentioned no longer appears in the Laravel log. Admittedly I'm still not sure as to the cause of the initial playing issues when the app was Dockerized, but I think this bare metal solution works fine.

Closing for now.

A little update:

I tried running Koel by pulling down the "master" branch and putting it on the box (where many other Laravel apps reside!) and it worked first try with one caveat: the header error kept appearing in the logs in the bare metal instance too.

The music is playing on the bare metal instance completely fine, with none of the PARTIAL_TRANSFER errors found when trying to play music on the Dockerized app. Both apps are pulling music from the same folder.

<!-- gh-comment-id:3194691861 --> @lewislarsen commented on GitHub (Aug 17, 2025): Update two: I just switched my Koel instance to use `x-accel-redirect` method and the PHP error I mentioned no longer appears in the Laravel log. Admittedly I'm still not sure as to the cause of the initial playing issues when the app was Dockerized, but I think this bare metal solution works fine. Closing for now. A little update: I tried running Koel by pulling down the "master" branch and putting it on the box (where many other Laravel apps reside!) and it worked first try with one caveat: the header error kept appearing in the logs in the bare metal instance too. The music is playing on the bare metal instance completely fine, with none of the PARTIAL_TRANSFER errors found when trying to play music on the Dockerized app. Both apps are pulling music from the same folder.
Author
Owner

@lewislarsen commented on GitHub (Aug 22, 2025):

Hi there.

Unfortunately, I have to reopen this as the problem noted in the original issue has appeared in my bare-metal deployment of Koel.

The only change recently has been a recent deployment of code from the master branch, and the subsequent running of php artisan koel:init in the deployment script. Seeing the code that was pushed to the branch I doubt it's related in any way.

It does seem like the Laravel logs and the error in browser are related as they've both appeared.

Logs:

Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /home/ploi/redacted.larsens.dev/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php:322 Stack trace: #0 /home/ploi/redacted.larsens.dev/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->

Cannot modify header information - headers already sent by (output started at /home/ploi/redacted.larsens.dev/vendor/daverandom/resume/src/DefaultOutputWriter.php:30)

Browser:

01:49:19.734 An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. app-B7sUZl9B.js:42:2728
01:49:25.342
[koel] 
error { target: audio.hidden, isTrusted: true, srcElement: audio.hidden
, eventPhase: 0, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, timeStamp: 7760, … }

bubbles: false

cancelBubble: false

cancelable: false

composed: false

currentTarget: null

defaultPrevented: false

eventPhase: 0

explicitOriginalTarget: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]">

isTrusted: true

originalTarget: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]">

returnValue: true

srcElement: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]">
target: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]">

timeStamp: 7760

type: "error"

<get isTrusted()>: function isTrusted()

<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
<anonymous code>:1:145535
    overrideMethod <anonymous code>:1
    error https://[REDACTED].larsens.dev/build/assets/socketService-DWdLcY99.js:609
    onError https://[REDACTED].larsens.dev/build/assets/app-B7sUZl9B.js:45
01:49:26.786
[koel] 
error { target: audio.hidden, isTrusted: true, srcElement: audio.hidden
, eventPhase: 0, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, timeStamp: 9205, … }
<anonymous code>:1:145535
01:49:27.157
GET
https://[REDACTED].larsens.dev/build/assets/default-CxrI6z8D.svg
[HTTP/1.1 200 OK 0ms]

01:49:27.343
GET
https://[REDACTED].larsens.dev/play/[REDACTED]?t=19|[REDACTED]
Blocked

This error presents itself in both on web and via the mobile app, however the song is able to play to completion on the mobile app. On Firefox no audio is played.

I'm not too sure if my nginx site config file will be useful here, but as I'm using x-accel-redirect it seemed like a good idea to include. I've redacted the subdomain itself.

# Ploi Webserver Configuration, do not remove!
include /etc/nginx/ploi/redacted.larsens.dev/before/*;

server {
    #listen 80;
    #listen [::]:80;

    root /home/ploi/redacted.larsens.dev/public;
    server_name redacted.larsens.dev;

    include /etc/nginx/ssl/redacted.larsens.dev;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ecdh_curve X25519:prime256v1:secp384r1;
    ssl_ciphers SNIP;
    ssl_prefer_server_ciphers off;
    ssl_dhparam /etc/nginx/dhparams.pem;

    index index.php index.html;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    charset utf-8;

    gzip            on;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;
    gzip_comp_level  9;

    send_timeout    3600;
    client_max_body_size  50M;

    # Ploi Configuration, do not remove!
    include /etc/nginx/ploi/redacted.larsens.dev/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /media/ {
        internal;
        alias       $upstream_http_x_media_root;
        #access_log /var/log/nginx/koel.access.log;
        #error_log  /var/log/nginx/koel.error.log;
    }

    access_log off;
    error_log  /var/log/nginx/redacted.larsens.dev-error.log error;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
        fastcgi_buffers 32 32k;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# Ploi Webserver Configuration, do not remove!
include /etc/nginx/ploi/redacted.larsens.dev/after/*;

Here are the nginx errors logs, much of the same from the Laravel log really.

#0 /home/ploi/redacted.larsens.dev/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():255}()
#2 /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php(322): header()
#3 /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php(401): Symfony\Component\HttpFoundation\Response->sendHeaders()
#4 /home/ploi/redacted.larsens.dev/vendor/laravel/framework/src/Illuminate/Foundatio
2025/08/22 01:32:56 [error] 9768#9768: *704 upstream prematurely closed FastCGI request while reading upstream, client: XX.XXX.XX.XX, server: redacted.larsens.dev, request: "GET /play/9fae4b74-f228-44fc-a881-78b0118493ac?t=13%7C2qo4jDMggXNh0w1mAYpoPKsas8rD7WdyBKAFLVoR3008f76c HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.4-fpm.sock:", host: "redacted.larsens.dev"
2025/08/22 01:34:08 [error] 9769#9769: *718 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /home/ploi/redacted.larsens.dev/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php:322
Stack trace:

If you need any specific or additional information about my configuration, please do let me know. I do apologize for the length of this reply but I hope it might be useful in potentially discovering what's going awry.

<!-- gh-comment-id:3212590128 --> @lewislarsen commented on GitHub (Aug 22, 2025): Hi there. Unfortunately, I have to reopen this as the problem noted in the original issue has appeared in my bare-metal deployment of Koel. The only change recently has been a recent deployment of code from the master branch, and the subsequent running of `php artisan koel:init` in the deployment script. Seeing the code that was pushed to the branch I doubt it's related in any way. It does seem like the Laravel logs and the error in browser are related as they've both appeared. Logs: ``` Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /home/ploi/redacted.larsens.dev/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php:322 Stack trace: #0 /home/ploi/redacted.larsens.dev/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions-> Cannot modify header information - headers already sent by (output started at /home/ploi/redacted.larsens.dev/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) ``` Browser: ``` 01:49:19.734 An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. app-B7sUZl9B.js:42:2728 01:49:25.342 [koel] error { target: audio.hidden, isTrusted: true, srcElement: audio.hidden , eventPhase: 0, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, timeStamp: 7760, … } bubbles: false cancelBubble: false cancelable: false composed: false currentTarget: null defaultPrevented: false eventPhase: 0 explicitOriginalTarget: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]"> isTrusted: true originalTarget: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]"> returnValue: true srcElement: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]"> target: <audio class="hidden" crossorigin="anonymous" title="[REDACTED]" src="https://[REDACTED].larsens.dev/audio/[REDACTED]"> timeStamp: 7760 type: "error" <get isTrusted()>: function isTrusted() <prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … } <anonymous code>:1:145535 overrideMethod <anonymous code>:1 error https://[REDACTED].larsens.dev/build/assets/socketService-DWdLcY99.js:609 onError https://[REDACTED].larsens.dev/build/assets/app-B7sUZl9B.js:45 01:49:26.786 [koel] error { target: audio.hidden, isTrusted: true, srcElement: audio.hidden , eventPhase: 0, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, timeStamp: 9205, … } <anonymous code>:1:145535 01:49:27.157 GET https://[REDACTED].larsens.dev/build/assets/default-CxrI6z8D.svg [HTTP/1.1 200 OK 0ms] 01:49:27.343 GET https://[REDACTED].larsens.dev/play/[REDACTED]?t=19|[REDACTED] Blocked ``` This error presents itself in both on web and via the mobile app, however the song is able to play to completion on the mobile app. On Firefox no audio is played. I'm not too sure if my nginx site config file will be useful here, but as I'm using `x-accel-redirect` it seemed like a good idea to include. I've redacted the subdomain itself. ``` # Ploi Webserver Configuration, do not remove! include /etc/nginx/ploi/redacted.larsens.dev/before/*; server { #listen 80; #listen [::]:80; root /home/ploi/redacted.larsens.dev/public; server_name redacted.larsens.dev; include /etc/nginx/ssl/redacted.larsens.dev; ssl_protocols TLSv1.2 TLSv1.3; ssl_ecdh_curve X25519:prime256v1:secp384r1; ssl_ciphers SNIP; ssl_prefer_server_ciphers off; ssl_dhparam /etc/nginx/dhparams.pem; index index.php index.html; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; charset utf-8; gzip on; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json; gzip_comp_level 9; send_timeout 3600; client_max_body_size 50M; # Ploi Configuration, do not remove! include /etc/nginx/ploi/redacted.larsens.dev/server/*; location / { try_files $uri $uri/ /index.php?$query_string; } location /media/ { internal; alias $upstream_http_x_media_root; #access_log /var/log/nginx/koel.access.log; #error_log /var/log/nginx/koel.error.log; } access_log off; error_log /var/log/nginx/redacted.larsens.dev-error.log error; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php/php8.4-fpm.sock; fastcgi_buffers 32 32k; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } } # Ploi Webserver Configuration, do not remove! include /etc/nginx/ploi/redacted.larsens.dev/after/*; ``` Here are the nginx errors logs, much of the same from the Laravel log really. ``` #0 /home/ploi/redacted.larsens.dev/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():255}() #2 /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php(322): header() #3 /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php(401): Symfony\Component\HttpFoundation\Response->sendHeaders() #4 /home/ploi/redacted.larsens.dev/vendor/laravel/framework/src/Illuminate/Foundatio 2025/08/22 01:32:56 [error] 9768#9768: *704 upstream prematurely closed FastCGI request while reading upstream, client: XX.XXX.XX.XX, server: redacted.larsens.dev, request: "GET /play/9fae4b74-f228-44fc-a881-78b0118493ac?t=13%7C2qo4jDMggXNh0w1mAYpoPKsas8rD7WdyBKAFLVoR3008f76c HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.4-fpm.sock:", host: "redacted.larsens.dev" 2025/08/22 01:34:08 [error] 9769#9769: *718 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ErrorException: Cannot modify header information - headers already sent by (output started at /home/ploi/redacted.larsens.dev/vendor/daverandom/resume/src/DefaultOutputWriter.php:30) in /home/ploi/redacted.larsens.dev/vendor/symfony/http-foundation/Response.php:322 Stack trace: ``` If you need any specific or additional information about my configuration, please do let me know. I do apologize for the length of this reply but I hope it might be useful in potentially discovering what's going awry.
Author
Owner

@lewislarsen commented on GitHub (Aug 22, 2025):

Hey @phanan I have some bad news.

Thank you so much for your commit, but unfortunately there's been no change and this problem still persists. The instance is using the latest deployment of the master branch, commit 3825034b8b.

Even if php or x-accel-redirect is specified in the .env, this issue still happens.

Firefox, Chrome or Safari all produce the same problem.

I'm not really sure what's the specific issue with my environment that's causing this, but I'll try to list everything I can that I can think of.

Server Configuration

Nginx: 1.28.0
PHP: 8.4.11
OS: Ubuntu 24.04.3 LTS
Postgres: (PostgreSQL) 17.6 (Ubuntu 17.6-1.pgdg24.04+1)
Redis: Redis server v=7.0.15
Node: v20.19.4
Application Version: Koel v7.12.0 Community Edition (Commit 3825034b8b from /koel/koel master branch)

The application is deployed via Ploi but it only provides an interface, it doesn't manage or make extraordinary changes.

Here is the output of php artisan koel:doctor

ploi@serenity:~/redacted.larsens.dev$ php artisan koel:doctor


                                                                       CHECKING KOEL SETUP...


  Artifacts directory /home/ploi/koel_artifacts/ is readable/writable ........................................................................... OK
  Session directory storage/framework/sessions is readable/writable ............................................................................. OK
  Cache directory storage/framework/cache is readable/writable .................................................................................. OK
  Log directory storage/logs is readable/writable ............................................................................................... OK
  Checking database connection .................................................................................................................. OK
  Media storage setup (local) ................................................................................................................... OK
  TNT search index directory storage/search-indexes is readable/writable ........................................................................ OK
  API is healthy ................................................................................................................................ OK
  FFmpeg binary /usr/bin/ffmpeg is executable ................................................................................................... OK
  PHP extension zip is loaded. Multi-file downloading is supported .............................................................................. OK
  Max upload size ............................................................................................................................ 1024M
  Max post size .............................................................................................................................. 1024M
  Streaming method ................................................................................................................ x-accel-redirect
  Last.fm integration ................................................................................................................ Not available
  YouTube integration ................................................................................................................ Not available
  Spotify integration ........................................................................................................................ ERROR
  Mailer configuration .......................................................................................................................... OK
  Koel scheduler status .................................................................................................................. Installed
  Koel Plus license status ........................................................................................................... Not available

   ERROR  There are errors in your Koel setup. Koel will not work properly.

   ERROR  You can find more details in storage/logs/laravel.log.

ploi@serenity:~/redcated.larsens.dev$

For what it's worth, the Spotify error is [KOEL.DOCTOR] Class "Faker\Factory" not found as per the logs, but this existed whilst the bare metal instance was functioning and able to play music via web browsers.

<!-- gh-comment-id:3214135562 --> @lewislarsen commented on GitHub (Aug 22, 2025): Hey @phanan I have some bad news. Thank you so much for your commit, but unfortunately there's been no change and this problem still persists. The instance is using the latest deployment of the master branch, commit [3825034b8b](https://github.com/koel/koel/commit/3825034b8bf311bc42b7f3188594ca1d112ffc23). Even if `php` or `x-accel-redirect` is specified in the `.env`, this issue still happens. Firefox, Chrome or Safari all produce the same problem. I'm not really sure what's the specific issue with my environment that's causing this, but I'll try to list everything I can that I can think of. **Server Configuration** Nginx: 1.28.0 PHP: 8.4.11 OS: Ubuntu 24.04.3 LTS Postgres: (PostgreSQL) 17.6 (Ubuntu 17.6-1.pgdg24.04+1) Redis: Redis server v=7.0.15 Node: v20.19.4 Application Version: Koel v7.12.0 Community Edition (Commit 3825034b8b from /koel/koel master branch) The application is deployed via [Ploi](https://ploi.io) but it only provides an interface, it doesn't manage or make extraordinary changes. Here is the output of `php artisan koel:doctor` ``` ploi@serenity:~/redacted.larsens.dev$ php artisan koel:doctor CHECKING KOEL SETUP... Artifacts directory /home/ploi/koel_artifacts/ is readable/writable ........................................................................... OK Session directory storage/framework/sessions is readable/writable ............................................................................. OK Cache directory storage/framework/cache is readable/writable .................................................................................. OK Log directory storage/logs is readable/writable ............................................................................................... OK Checking database connection .................................................................................................................. OK Media storage setup (local) ................................................................................................................... OK TNT search index directory storage/search-indexes is readable/writable ........................................................................ OK API is healthy ................................................................................................................................ OK FFmpeg binary /usr/bin/ffmpeg is executable ................................................................................................... OK PHP extension zip is loaded. Multi-file downloading is supported .............................................................................. OK Max upload size ............................................................................................................................ 1024M Max post size .............................................................................................................................. 1024M Streaming method ................................................................................................................ x-accel-redirect Last.fm integration ................................................................................................................ Not available YouTube integration ................................................................................................................ Not available Spotify integration ........................................................................................................................ ERROR Mailer configuration .......................................................................................................................... OK Koel scheduler status .................................................................................................................. Installed Koel Plus license status ........................................................................................................... Not available ERROR There are errors in your Koel setup. Koel will not work properly. ERROR You can find more details in storage/logs/laravel.log. ploi@serenity:~/redcated.larsens.dev$ ``` For what it's worth, the Spotify error is `[KOEL.DOCTOR] Class "Faker\Factory" not found` as per the logs, but this existed whilst the bare metal instance was functioning and able to play music via web browsers.
Author
Owner

@phanan commented on GitHub (Aug 22, 2025):

DefaultOutputWriter is only used for PHP native streaming, so I've no idea why it would yield any issue for x-accel-redirect. If any, it suggests some problem with your system. For example, I notice that you're using PHP 8.4, which can be quite noisy about deprecations — maybe try to disable them.

<!-- gh-comment-id:3214249270 --> @phanan commented on GitHub (Aug 22, 2025): `DefaultOutputWriter` is only used for PHP native streaming, so I've no idea why it would yield any issue for `x-accel-redirect`. If any, it suggests some problem with your system. For example, I notice that you're using PHP 8.4, which can be quite noisy about deprecations — maybe try to disable them.
Author
Owner

@phanan commented on GitHub (Aug 22, 2025):

Actually, what you said:

I just switched my Koel instance to use x-accel-redirect method and the PHP error I mentioned no longer appears in the Laravel log. Admittedly I'm still not sure as to the cause of the initial playing issues when the app was Dockerized, but I think this bare metal solution works fine.

makes perfect sense and is aligned with the issue found (and fixed): For PHP streaming method, the song data was sent by DefaultOutputWriter and (due to a bug) Laravel/Symfony tried to send more headers, which broke. This should NOT happen with x-accel-redirect simply because this method doesn't involve DefaultOutputWriter at all.

So, if you're saying the same issue happens for x-accel-redirect, I've no idea why. Please check if it's indeed the same issue.

<!-- gh-comment-id:3214269832 --> @phanan commented on GitHub (Aug 22, 2025): Actually, what you said: > I just switched my Koel instance to use `x-accel-redirect` method and the PHP error I mentioned no longer appears in the Laravel log. Admittedly I'm still not sure as to the cause of the initial playing issues when the app was Dockerized, but I think this bare metal solution works fine. makes perfect sense and is aligned with the issue found (and fixed): For PHP streaming method, the song data was sent by `DefaultOutputWriter` and (due to a bug) Laravel/Symfony tried to send more headers, which broke. This should NOT happen with `x-accel-redirect` simply because this method doesn't involve `DefaultOutputWriter` at all. So, if you're saying _the same issue_ happens for `x-accel-redirect`, I've no idea why. Please check if it's indeed the same issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#1084
No description provided.