'fclose(): Argument #1 ($stream) must be of type resource, bool given
I just restart my laravel 8.0 project and I got this below error, please what could be wrong, this happens anytime I run "PHP artisan serve"
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()
Solution 1:[1]
You can open the task manager then look for CLI (with the php logo) background process, if you find it then the kill task
Solution 2:[2]
I had a Laravel application running that I forgot about (in the terminal of another IDE). Ctl + C (killing) that allowed me to get past this error msg.
Solution 3:[3]
Don't restart, don't uninstall, don't panic !
If you are on Windows Machine then follow these below step :
Click the Start charm.
Type cmd, right-click the Command Prompt tile, and then click Run as administrator.
Type
tasklist /v | find "php"press enter and find the PID of php.exeKill the process by
taskkill /PID <PID> /FYou are done.
Solution 4:[4]
I had the same error today and applied all the solutions but this resolved my error.
- Un-install the composer.
- Restart your machine
- Install the composer
Solution 5:[5]
First run composer install before trying to start the dev server using php artisan serve. You might also have to generate the key using php artisan key:generate incase the app starts with errors.
Solution 6:[6]
I encountered same issues I hope this solution help someone else:
1. Delete the **vendor** folder/directory of the project
2. run **"composer install"** to install packages.
That fixed my issues.
Solution 7:[7]
I've solved this issue by searching the process that was keeping open the file sf_proc_00.err within %LOCALAPPDATA%\Temp (the local Windows temp directory). Process Explorer or similar tools can be used for this. It was locked by ssh.exe (very likely launched by git). After killing the process, composer runs normally again.
Solution 8:[8]
You should clear the config cache using optimize:clear command:
php artisan optimize:clear
Solution 9:[9]
The solution is very easy, just do
php artisan config:clear
Then rerun
php artisan serve
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Andrew Koper |
| Solution 3 | sta |
| Solution 4 | Dharman |
| Solution 5 | |
| Solution 6 | Doro |
| Solution 7 | hammurabi |
| Solution 8 | Shreyansh Panchal |
| Solution 9 | cigien |
