How To Fix: FastCGI sent in stderr – PHP message: PHP Warning: move_uploaded_file

PHP Warning: move_uploaded_file is a typical web server error with Nginx and appears when we want to upload a file to the server. Most of the time, when we have to upload certificates or other files that do not belong to “Media”, we don't see the error in the CMS administration interface.

In a more concrete form, the error “PHP Warning: move_uploaded_file” we find it in error.log as:

FastCGI sent in stderr: "PHP message: PHP Warning:  move_uploaded_file(/srv/www/domain.test/public/file.file): failed to open stream: Permission denied in /srv/www/domain.test/public/script.php on line 748 PHP message: PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpqAVtWy'

Why the error occurs PHP Warning: move_uploaded_file and how we solve it

As I said above, the error occurs when we try to upload files to the web server.

"FastCGI sent in stderr”Is typical for servers that have PHP-FPM and Nginx as software for the web. So the problem is somewhere in the relation of the script through which the files are uploaded.

"move_uploaded_file(): Unable to move”Tells us very clearly that those files cannot be uploaded and moved to another folder on the web server by the script that performs the operation.

Resolve this error PHP it is solved very simply, setting the correct permissions on the server, both for the execution script, to which the most probable user: nginx did not have access, and for the destination folder.

If the website files do not belong to a user, as it is on cPanel, VestaCP or other hosting management platforms, then almost certainly the solution is to give the nginx user access to the upload folder and the script.

For the above code example, we will execute the following command in SSH:

chown -R nginx:nginx /srv/www/domain.test/public/
chmod g+w file.file

We resume uploading and everything should work without error move_uploaded_file(): Unable to move.

If you still encounter problems, it can be solved in the comments of this tutorial.

Passionate about technology, I enjoy writing on StealthSettings.com since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

How to » Tutorials and IT News » How To Fix: FastCGI sent to stderr – PHP message: PHP Warning: move_uploaded_file

1 thought on “How To Fix: FastCGI sent in stderr – PHP message: PHP Warning: move_uploaded_file”

  1. Hello,
    J'ai lu et relu vos articles sur le sujet [move_upload_file].
    Il se trouve que je suis confonn avec ce problème et que je cherche depuis moult mois de m'en sortir sans succès.
    I have a personal site in which I have a page Formaire.html that does not function only partially, to know: it is impossible to open the flow etc... and it is safe to move them in 'uploads'.
    Je suis retraité des Arts graphiques, typographe à 13 ans, puis monteur offset, infographiste, webmaster, bref j'ai 84 ans retraité et je suis toujours et encore passionné par mon métier.
    Si je me débrouille avec le html et le JavaScript, je me heurte aujourd'hui au PHP.
    I do with my colleagues anciens combattant d'Algérie, de petites sorties et réalise des "reportages" that I put on my site Perso à dispo pour ceux qui sont intéressés; donc, je désire recevoir des docs car je ne pas tout faire moi même pour illustrer mes propos, d'où l'idée du Formulaire et traitement PHP.
    I created my site with "Dreamweaver CC2020", version Mac hébergé chez moi sur un serveur Synology “Ngnix” DMS v. 7.1 – PHP 8 (possibilité php 7.2, php 7.3, php 7.4). Default certificate (No-Ip): TrustCor DV CA – G2 RSA
    The Form works correctly for the "text" fields, but refuses the "media" fields.
    If you want it, you can connect to the URL above, click on the figurine and as I don't have to activate the html "return", you can visualize the result in the PHP page. (I have allocated 10 Mb and 20 Mb) for the media.
    Et si je vous suis bien, le soucis viendrait du “FastCGI” des serveurs Nginx PHP-TPM ce qui est mon cas, alors dans le volet TPM, il existe bien moult cases à cocher ou décocher, mais les quelles?
    I noticed the SSH command:
    chown -R nginx:nginx /srv/www/domain.test/public/
    chmod g+w file.file
    Mais conviendra-t-telle à mon serveur?
    Merci par avance de vos précieux conseils

    Reply
Leave a Comment