PHP fopen "failed to open stream: resource temporarily unavailable"

13,310

Solution 1

It could only be one of a few things:

  • The PHP process is out of memory, file handles, or similar
  • The PHP environment's own limitations are exceeded somehow
  • The file itself has some limitation, such as a SELinux (Security Enhanced Linux) restriction.

To determine which it is, try opening the file outside PHP. Temporarily alter the script to open a different file. Look at what else the script does to validate whether it could possibly be running out of file handles, etc.

Solution 2

What does is_file($queryFile) and is_writable($queryFile) reveal? Maybe you are not in the correct working directory?

Share:
13,310
EthanLWillis
Author by

EthanLWillis

Updated on June 06, 2022

Comments

  • EthanLWillis
    EthanLWillis almost 2 years

    EDIT: Austin below in the comments resolved my issue. How do I close the question since that is the answer?

    I have the following simple code to open/write to a query file on my server. I've checked permissions and even set +rw for all users on the query file, yet I still get the error

    failed to open stream: resource temporarily unavailable

    in my apache error log.

    I'm not really sure what I can do to alleviate this issue, thoughts?

    <?php 
    // filepaths
    $queryFile = '../query/query.txt';
    
    // get query
    $query = $_GET['searchBox'];
    
    // open and write query to query file
    $fh = fopen($queryFile, 'X') or die("Can't open file");
    fwrite($fh, $query);
    fclose($fh);
    
  • cnnr
    cnnr almost 5 years
    It's not an answer, it should be a comment.