38

After every execution, regardless of said execution - when using Chrome web browser the PHP local server throws this error:

Invalid request (Unexpected EOF) \n

It's not causing any visible issues; however as it's a persistent issue I was wondering if something may bite me later.

Any ideas?

Note: it happens roughly 10 seconds after any page is executed.

Further note: This happens after all executions, even when the files are ended correctly:

<?php echo 'hey'; ?> 

would still throw the aforementioned error.

[Thu Mar 19 09:39:55 2015] 127.0.0.1:53923 [200]: /admin [Thu Mar 19 09:40:05 2015] 127.0.0.1:53924 Invalid request (Unexpected EOF)

This is the full error.

Jack hardcastle
  • 2,748
  • 4
  • 22
  • 40
  • Does it give a line number in the error? If so post the 1 preceding line before it? – meowfishcat Mar 19 '15 at 09:46
  • I've added the full error that displays (second line) after a successful execution (first line) at the end of my post. – Jack hardcastle Mar 19 '15 at 09:47
  • 1
    What version of PHP? Seems to be related to this bug -> https://bugs.php.net/bug.php?id=60471 Upgrade your PHP to a newer version. – davidkonrad Mar 19 '15 at 10:06
  • 2
    After discussing with OP it seems it might be a Chrome extension throwing the error, as with all extensions disabled (in incognito) it does not throw the error - not entirely sure why this might be. – meowfishcat Mar 19 '15 at 10:23
  • 4
    Its happening in FF as well. – maan81 Jul 24 '15 at 03:21
  • It happened in Firefox just now to me when running AJAX with Laravel. Code worked perfectly 5 minutes ago, and now like magic, no request is going through anymore – Eric McWinNEr Aug 08 '19 at 12:42

10 Answers10

42

This is a known bug.

From https://bugs.php.net/bug.php?id=60471:

[2011-12-08 15:01 UTC] lolautruche at gmail dot com Description:
------------
From time to time, built-in server with router script logs this kind of stuff :

[Thu Dec 8 13:39:29 2011] 127.0.0.1:50358 Invalid request (Unexpected EOF)

This happens quite randomly, whatever the script has a close tag or not, whatever it has a blank line after close tag or not.

And the explanation:

[2012-02-23 18:45 UTC] michal dot pipa dot xsolve at gmail dot com
...
Chromium has feature called "Predict network actions to improve page load performance" and its enabled by default. It works this way, that if HTML page has links to some resources, than Chromium opens about 10 TCP connections in advance. And then if browser has less than 10 resources to fetch, unused connections times out after 10 seconds. And this (empty payload) causes PHP server to display "Invalid request (unexpected EOF)" message.

It is a harmless error from the PHP built-in server.

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
Gary
  • 2,293
  • 2
  • 25
  • 47
3

This could be related to Chrome specifically and its network prediction feature. So try to disable that feature first. That's why it works for you in Incognito mode, because probably it's disabled in that mode.

You can find this option in Chrome Settings and click on 'Show advanced settings'. Should be there in Privacy section.

Use a prediction service to help complete searches and URLs typed in the address bar or the app launcher search box

kenorb
  • 155,785
  • 88
  • 678
  • 743
  • Where do I find this configuration? – Jack hardcastle Mar 19 '15 at 10:54
  • @Jackhardcastle Updated info. – kenorb Mar 19 '15 at 10:56
  • Unfortunately the error is still produced, it's strange - a 17 second delay between execution and the error displaying in terminal haha – Jack hardcastle Mar 19 '15 at 10:57
  • 1
    You can try sniff that via `sudo tcpdump -i lo -nl -w- port 80 | strings` to see exactly what this bad request is. – kenorb Mar 19 '15 at 11:01
  • @Jackhardcastle Or try to restart the web-browser, maybe the option option is disabled on restart. Or try similar options such as 'Enable phishing and malware protection.', or ''Use a web service to help resolve navigation errors.', just temporary to make sure it's not one of the other features which make some weird requests. – kenorb Mar 19 '15 at 11:04
3

On Laravel, I realize this thread hasn't been active for a while now but I found a solution completely unrelated to what other people have been posting. So I realized that I was getting this very error because I didn't have an application key set for my application. You can find out more about application keys in this other Stack Overflow question. Before attempting to generate an application key, make sure you've run the following command in the root directory of your application.

composer install

From what I've read, when you create a new application via the

laravel new application

command, you should have a file called .env by default. This was not my case, I had to rename the .env.example file to .env manually. Once you have done the two above steps, run this command in the root directory of your app

php artisan key:generate

This solved the OP's error for me. Hope it can help someone in the future.

Gaboik1
  • 353
  • 3
  • 15
3

This is bug on PHP. It was fixed on PHP 7.2

rsc
  • 10,348
  • 5
  • 39
  • 36
1

On Laravel 4.2, I resolve that when I clear the cache with command : php artisan cache:clear


Complete list of commands is available with : php artisan list

Nolwennig
  • 1,613
  • 24
  • 29
0

I started to encounter this phenomenon just recently with both Firefox and Chrome. I can't confirm nor deny any problems with browser plugins. Since I hadn't change anything in my development environment I started to look for other possibilities. Turns out it was the real time scan engine of the new version of my antivirus program. Once I excluded my project build folders, the php installation folder and php.exe from the scanning the problems with sudden eof occurrences instantly vanished. Maybe this helps some of you.

codar
  • 1
0

I confirmed that @user194714's suggestion is indeed a reason (maybe not the only one though). I'm using WordPress 4.7.1 and changing wp-admin/about.php @ line 55 resolved this issue. More importantly, the page loaded faster after this simple change. I will let WordPress maintainers know.

0

In my case, I'm using laravel 5.1 + AngularJs and I had removed the route:

**Route::get('/', function () {
    return view('app');
});**

I put this back and now it works fine.

Touheed Khan
  • 2,149
  • 16
  • 26
0

I had this error when running PHP on port 9000; after changing it to 8000 the error disappeared.

Das_Geek
  • 2,775
  • 7
  • 20
  • 26
Daniel Kukula
  • 333
  • 3
  • 7
-3

I see this behaviour when in index.html

<script src="main.js"></script>

is replaced with

<script src="main.js" />

(instead of closing </script> tag its short version is used />).

mp31415
  • 6,531
  • 1
  • 44
  • 34