Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sheriffgrandeur's avatar

fclose(): Argument #1 ($stream) must be of type resource, bool given

I am getting this when I try to restart my server on my laravel 8 project

Does anyone know what could be wrong?

TypeError

fclose(): Argument #1 ($stream) must be of type resource, bool given

at C:\Users\owner\Laravel-App\test-app\vendor\symfony\process\Pipes\WindowsPip es.php:74 70▕ fclose($this->lockHandles[$pipe]); 71▕ } 72▕ $this->lockHandles[$pipe] = $h; 73▕ ➜ 74▕ if (!fclose(fopen($file, 'w')) || !$h = fopen($file , 'r')) { 75▕ flock($this->lockHandles[$pipe], \LOCK_UN); 76▕ fclose($this->lockHandles[$pipe]); 77▕ unset($this->lockHandles[$pipe]); 78▕ continue 2; continue 2;

1 C:\Users\owner\Laravel-App\test-app\vendor\symfony\process\Pipes\WindowsPi pes.php:74 fclose()

2 C:\Users\owner\Laravel-App\test-app\vendor\symfony\process\Process.php:130 4 Symfony\Component\Process\Pipes\WindowsPipes::__construct()

0 likes
13 replies
jlrdw's avatar

Somewhere a true false is being passed instead of a resource.

Don't know if you modified anything.

Did you by chance do an update / upgrade without first updating laravel?

Laravel needs updating before updating / upgrading the framework.

Sheriffgrandeur's avatar

thank you for replying, I notice this error happen to be on my computer(i am using window), it's affecting the composer, i.e I am getting this error too when I try to run any composer cmd, I wonder what could be wrong, I did not change or modify anything on my computer though, thanks

jlrdw's avatar

If you using a later version of PHP, try updating. composer.

2 likes
Sheriffgrandeur's avatar

hello, if I try to run any composer command(like composer update) I am getting this error too..

yserrata's avatar

I was going through the same thing, but my problem was caused by a bad table relation that caused a permutation of the data. I corrected this issue then I ran Composer update, php artisan optimize and everything is working very wel

tmbenhura's avatar

After a long struggle: It is because of a bad Windows update that seems to have been fixed. Update your OS.

2 likes
jackson51002's avatar

@tmbenhura I love it when the solution to such a tedious issue, one that you spend hours researching, turns out to be so simple. thank you! :)

nathanvercaemert's avatar

As @tmbenhura said, updating my OS (Windows) solved this. As a temporary fix, if you are desperate, I had success before with the following steps:

  1. Uninstall Composer.
  2. Restart.
  3. Install Composer.

I had to do this any time I wanted to do anything, which obviously got to be annoying.

z3ykola's avatar

Maybe you forgot to shutdown artisan server "php artisan serve" It happened to me and solved this way

3 likes
Christofer's avatar

@z3ykola Perfect! Damn A.I. didn't even tell me this. Even while running on my IDE and after asking a couple different ways.

Please or to participate in this conversation.