DevLika
DevLika

Reputation: 31

How to fix: "Failed to start the session because headers have already been sent by "php://input" at line 1."

I literally don't know why this error suddenly appeared in my Symfony application version 4.4, without any changes suddenly the error started to be triggered:

Uncaught PHP Exception RuntimeException: "Failed to start the session because headers have already been sent by "php://input" at line 1." at /vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php line 152 {"exception":"[object] (RuntimeException(code: 0): Failed to start the session because headers have already been sent by \"php://input\" at line 1. at /vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:152)"}

The problem, when I try to go in a page that is using a session this error is appearing.

My env:

When it is appearing?

When I try to connect myself on a login page or another page that is using a session.

What did I try?

The non permanent solution here is for me to restart my php container all the time I receive that error, but as you can see it is not a permanent solution.

On my dev env I cannot reproduce it.

If anyone has a solution for it please let me know I have been looking and trying to get answers during days now and even asked questions in Symfony slack support without any answer to help me.

Thanks a lot for the help.

Upvotes: 1

Views: 5061

Answers (1)

DevLika
DevLika

Reputation: 31

After looking and searching for a response finally I got one from a post here in StackOverflow, I am letting here the answer in case it's gonna help anyone.

I did a composer update and unfortunately, it was not solved, but at least did update my dependencies.

The issue was caused by malware. By installing htop on my container I could see that malware named:

  • /tmp/kinsing and
  • /tmp/kdevtmpfsi

were taking all my CPU.

This was due to the fact that my local server had the 9000 port open for my PHP docker container, I had then to kill, remove them, and of course secure in a better way my container.

What should you check?

  • Install htop
  • Run htop
  • Check if there are any suspicious activities
  • Clean and secure your container by avoiding by example to use open ports

Upvotes: 2

Related Questions