Unable to Import Products CSV in WoocCommerce - 500 Internal Server Error

 Setting up a store but now you are stuck with the CSV import of your products? It happens and its frustrating when the error is not very descriptive. 

I faced a similar issue and after a lot of digging found a solution for the issue I was facing. 

Note that this guide isn't supposed to work in all cases, there may be many reasons why you may be seeing the same 500 Error in your console log when you try uploading a CSV. If you haven't checked your console log I recommend that you do because in most of the cases when it happens the front end UI of the import process screen won't show you anything. 



Now this site is on a shared hosting service, namely Bluehost, yours might be on some other providers like GoDaddy etc. But if it is a Linux server using cPanel most of the steps are going to be similar. 

I am not mentioning each and every step for every other provider as it will make this article very lengthy and not useful. I assume you already know your way around the hosting provider you are using. 

Check cPanel and error log

cPanel is the common platform to have WordPress on, on these shared hosting providers. 

Look for Advanced option or cPanel access on your hosting service's dashboard. Inside look for Error reporting or something similar, 

Fatal error: Maximum execution time of 30+2 seconds exceeded (terminated) in /home2/galaopti/public_html/wp-includes/class-wp-image-editor-imagick.php on line 370, referer: http://sh020.global.temp.domains/~galaopti/wp-admin/edit.php?post_type=product&page=product_importer&step=import&file=%2Fhome2%2Fgalaopti%2Fpublic_html%2Fwp-content%2Fuploads%2F2021%2F02%2FGOEXCELupdated-2-newcsv-galaoptics-4.csv&delimiter=%2C&_wpnonce=5af8eddfab

You have to match the data and time on these logs to make sure it is what exactly causing the problem. If you are seeing this "Maximum execution time of 30+2 seconds exceeded" it means the server is timing out.

If you are using something like Bitnami or a DigitalOcean / Ubuntu / Linux WordPress installation you should be looking into the Apache or MySQL error logs. 

Fixing the timeout issue

You have to set the max_execution_time to a higher number so that the server don't run out of resources while processing your import. 

Now there are 10s of guides available on the internet on how to do that, but whatever method you use make sure it is reflected - best way to check is by going to your WordPress admin dashboard then WooCommerce > Status > Look for "PHP Time Limit", it must display as something similar to what you set. 

If using the GUI option in your hosting provider's dashboard didn't work try editing wp-config.php file and use the set_time_limit(300) - this should be temporary, remove it once you are done. 

Did it work?

In most cases the above should work. However it did not in my case and I spent hours changing the timeout / max execution value on different files and settings on the hosting provider, none worked. 

What was the issue? Well, for me, I noticed it was a problem with the images. It were too large and taking forever to parse, probably not even 1 ever got parse due to server limits. 

Fix?

  • Use a tool like Windows Image Resizer. Because I tried upload an image using Media uploader and I got this error

    Post-processing of the image failed likely because the server is busy or does not have enough resources. Uploading a smaller image may help. Suggested maximum size is 2500 pixels.

    It meant even the first image in my CSV was having trouble going through. 

    I got the Image resizer tool and ran a resize action in bulk for all of the images. 

    Now you do not have to change the values in CSV again, you can work smartly by resizing the images and keeping its original names, then on your server just upload the files again by replacing the old ones, thus the URLs you put in the CSV will stay the same. 

  • Resize the image below 1600px (in width )

And voila! It worked! For extra measures I split my CSV into 4 different files so the whole process is split in 4 parts meaning less chances of the server overflowing due to heavy load.