How to fix the Function putenv() was disabled error in PrestaShop 1.7, 8.x, 9.x

Error Function putenv() was disabled by the domain protection module can surprise you at the most unexpected moment – especially after the store has been working flawlessly for a long time. In this post, I explain where this problem comes from and how to fix it quickly.

What exactly is putenv()?
putenv() is a built-in PHP function used to set environment variables during script execution. PrestaShop uses it, among other things, when handling localization and translations – it calls it when setting the locale for a given store language. Without this function, the store can still work, but warnings start appearing in the logs, and in some configurations errors can be visible directly on the page – which is of course unacceptable in production.

Where does this error come from?
The problem is characteristic of shared hosting that uses the mechanism domain protection (domain protection). This mechanism isolates individual domains from each other at the operating system level, which is a good security practice – but it also blocks certain PHP functions, including putenv(). The most popular case is hosting Cyber Folks and Hostido, which at some point began automatically enabling this option for every newly added domain or subdomain. The result? The store was working fine, you added a subdomain or switched a domain – and suddenly it started throwing warnings.
Warning
If the error appears directly on the store page (and not just in the logs), urgently disable PHP error display in the server configuration or the file config/defines.inc.php – visible errors on the front end are a serious reputation and security issue.
The full text of the warning looks like this:
User Warning: Function putenv() was disabled by the domain protection module. Disable domain protection for this domain in the Server Panel to use this function.

How to solve the problem – DirectAdmin panel (Cyber Folks or Hostido)
The solution is very simple and does not require any modifications to the store code. Just disable domain separation in the hosting panel.
  1. Log in to the panel DirectAdmin – usually available at domainname.pl:2222 or domainname.pl:2223
  2. Go to the section Domain settings
  3. Find your store's domain in the list
  4. Change the option Domain separation z YES to NO
  5. Save changes
Success
After disabling domain separation, the error should disappear immediately, without the need to restart the server or rebuild the PrestaShop cache.
błąd Function putenv() - wyłączenie

błąd Function putenv() - wyłączenie
What if I have a different hosting panel?
Not every hosting uses DirectAdmin. Below I have collected where to look for this option in other popular panels:
Hosting panelWhere to look for the setting
DirectAdmin (Cyber Folks)Domain settings – Domain separation – NO
cPanelPHP Selector or ModSecurity – check disabled PHP functions
PleskDomains – PHP settings – Disabled functions
HestiaCPNo built-in domain separation – check PHP-FPM configuration in /etc/php/X.X/fpm/pool.d/
Own server (VPS/dedicated)File php.ini or php-fpm.conf – directive disable_functions

Alternative solution – own server or no access to the panel
If you have access to the file php.ini or PHP-FPM configuration, check if putenv is not on the list of blocked functions:
disable_functions = putenv, ...
Delete putenv from this list and restart PHP-FPM:
systemctl restart php8.1-fpm
Note
Adjust the version number in the command above to the PHP version used by your store. You can check this in the hosting panel or through the file phpinfo().

Is it worth worrying about this error?
Yes. Although the store often works seemingly normally despite this warning:
  • the error may appear on the page for customers (depending on PHP error display configuration)
  • in some versions of PrestaShop, incorrect locale settings may cause problems with PDF invoice generation or email translations
  • accumulated warnings in logs make diagnosing actual problems difficult
Tip
After adding each new domain or subdomain to Cyber Folks hosting, go directly to domain settings and check the separation option – it enables automatically by default and it's better to disable it before the store starts generating errors.
Do you have other questions about PrestaShop configuration or hosting issues? Leave a comment below.

Leave Your comment

Your email address will not be published. Required fields are marked *

Shopping Cart

Close

Your cart is empty.

Start Shopping

Sidebar