PrestaShop error 500 – explained and how to troubleshoot
“500 Internal Server Error” or plain “Internal Server Error” is popular when installing and using any web platform. Not only PrestaShop but you might also encounter this error on WordPress, Shopify, Magento websites and so on. This disreputable HTTP Error 500 could turn an online store owner’s smile to a bewildered frown with one click. The fear of lost sales, it stonewalls your customers’ ability to browse your store and purchase products. For web developers, this error is a nightmare. Everyone has to scurry to get his or her stores back online.
As terrible as it sounds, it’s not too scary. On this post, I’ll explain the error and offer some troubleshooting ideas for your PrestaShop store. The next time you encounter this error, instead of hiding under your blanket, you’ll be prepared to act fast, handle the issue and keep on making deals. Even if you’re not using PrestaShop, these solutions can still worth to take a try.
How to perceive the HTTP Error 500
It’s necessary to not confound the HTTP Error 500 with the Error 404 Page Not Found. To deal with the error, firstly, we have to go over the various ways you may see this error message on your PC. There are different appearances of this message due to each host/server is permitted to adjust the way it’s shown. Here are some regular ways you may see this error.
- “500 Internal Server Error”
- “Internal Server Error”
- “500 Error”
- “HTTP 500 – Internal Server Error”
- “HTTP 500 Internal Error”
- “HTTP Error 500”
Most occasions you will see this message accompanied by different types of this classic familiar line “The server encountered an internal error or misconfiguration and was unable to complete your request”. And this error can appear on any web browser and any operating system. Here is a screen capture of one of the forms Error 500 may be displayed on your browser.
So, what is the HTTP Error 500?
Simply put, the Error 500 is the way your web server saying “Something turned out badly but I have no clue what it is!”
Well, it’s really unhelpful at all. But, the HTTP error logs can (and usually will) show you what has gone wrong.
How can I troubleshoot HTTP Error 500?
Each web server will have an error log.
For Apache servers, it is usually located at /var/log/apache/error.log. It will show you something like this:
[Thu Nov 22 12:59:12.862338 2018] [php7:error] [pid 3538] [client XX.XX.XX.XX:31504] PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 59462712 bytes) in /home/myuser/public_html/classes/Configuration.php on line 206
Again, not very helpful unless you recognize what these numbers mean. But don’t be worry, we still have another option.
Troubleshooting Error 500 for PrestaShop website
If your PrestaShop store is suffering from this error, you can get some detail information by turning on PrestaShop’s Error Reporting in the file “config/defines.inc.php”. There are 2 ways to turn on Error Reporting depending on what PrestaShop version you have.
For PrestaShop v1.4 through v1.5.2
- Open config/config.inc.php
- On or around line 29 you will find this line @ini_set(‘display_errors’, ‘off’);
- Change that line to read @ini_set(‘display_errors’, ‘on’);
For Prestashop v1.5.3 and higher versions
- Open config/defines.inc.php
- On or around line 28 you will find this line define(‘_PS_MODE_DEV_’, false);
- Change that line to read define(‘_PS_MODE_DEV_’, true);
Then back to the page that gave you the error once more, and you’ll see something like this:
[PrestaShopDatabaseException]
Db->executeS() must be used only with select, show, explain or describe queries at line 471 in file classes/db/Db.php
465.
466. // This method must be used only with queries which display results
467. if (!preg_match(‘#^\s*\(?\s*(select|show|explain|describe|desc)\s#i’, $sql))
OK, more info but still scary for us.
Just show me how to fix this error
For most PrestaShop store owner, you’ll want to know the most common ways this problem is caused so that you can try out some solutions yourself.
Here we have the best 5 reasons why Error 500 occurs, and what you can do to address them.
1. File and folder permission is wrong
Some servers that have SuPHP or Fast-CGI turned on can be especially sensitive to file and folder permissions. The right permission for files is 644 and folders is 755. If you see from the server logs or PrestaShop error report that file permissions may be the problem, try resetting the permissions with these commands:
find /home/USERNAME/public_html -type d -exec chmod 755 {} \;
find /home/USERNAME/public_html -type f -exec chmod 644 {} \;
Replace /home/USERNAME/public_html with the path to your web directory.
Note: Take a backup of your site before you execute any command
2. Incorrectly configured .htaccess file
Most of the times, you will receive an internal server error when the htaccess file is configured incorrectly. The main culprits of the htaccess errors are “URL Rewrite” settings or Friendly URL enabling. The htaccess syntax is very strict, if you add an incorrect command, or even an incorrect character, your server will return error 500.
Make a backup of your htaccess and regenerate the htaccess file either through the back office or by toggling the Enable Friendly URL option.
3. Server timeout
Every server has their own timeout setting, which sets the time that any given script can run. If the function or script crosses that limit, Error 500 will occur. The most common scripts in PrestaShop that may take too long to load are CSV Imports, backups, translation loading, import/exports and thumbnail regeneration.
Many server limits are set to 30 seconds, which is not long enough to run these scripts. You should contact your hosting provider and inquire about changing the limit, at least temporarily.
4. Low PHP memory limit
Many web hosts set the default memory allocation for PHP as 32 MB, 64 MB or 128 MB.
However, PrestaShop requires at least 128 MB to function and put in some more for modules if you need them. So, a suitable memory allocation is 256 MB. If you have a VPS, set it to 512 MB.
5. Missing PHP modules
A common issue seen with PrestaShop sites in VPSs is that they lack all the needed PHP modules.
To help PrestaShop function, we will need:
- Mcrypt
- OpenSSL
- Zip
- Curl
- GD
- PDO
To check if these modules are enabled for your website, copy the code below into “phpinfo.php” file and upload it to your site. Then open it in a browser, and check for these extensions.
<?
phpinfo();
?>
If any of those modules are missing, open your server’s php.ini file to see if it is enabled. If not, you’ll need to install them manually.
Note: Remember to delete the phpinfo.php file once you are done. Hackers could use that to target specific vulnerabilities.
The post PrestaShop error 500 – explained and how to troubleshoot appeared first on Presta Hero.
Comments
Post a Comment