{"id":11068,"date":"2026-06-03T13:33:52","date_gmt":"2026-06-03T13:33:52","guid":{"rendered":"https:\/\/www.hostinger.com\/support\/?p=11068"},"modified":"2026-11-24T04:28:58","modified_gmt":"2026-11-24T04:28:58","slug":"how-to-fix-mysql-operation-not-permitted-error","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/how-to-fix-mysql-operation-not-permitted-error\/","title":{"rendered":"How to fix MySQL &#8220;Operation not permitted&#8221; error"},"content":{"rendered":"<p>If your website is showing a database connection error such as:<\/p>\n<ul>\n<li>PHP Fatal error: Uncaught mysqli_sql_exception: Operation not permitted<\/li>\n<li>Connection failed: Operation not permitted<\/li>\n<li>ERROR: Could not connect. Operation not permitted<\/li>\n<li>SQLSTATE[HY000] [2002] Operation not permitted<\/li>\n<\/ul>\n<p>This means your website is likely opening a new MySQL connection on every page request, instead of reusing an existing one. Hostinger enforces a per-account MySQL connection rate limit (20 new connections per second) to ensure fair resource usage across all customers. Websites that open a fresh connection on every request can exceed this limit during traffic bursts, causing the error above.<\/p>\n<p>To resolve the error on a custom PHP website, switch to persistent MySQL connections. WordPress doesn\u2019t support persistent connections, so on a WordPress website, reduce the number of requests that open a database connection instead.<\/p>\n<h3>Before you start<\/h3>\n<ul>\n<li>You will need access to your website&#8217;s PHP files via Hostinger dashboard <a data-click-id=\"hgr-post-content-link-file-manager\" href=\"\/support\/4548688-basic-actions-in-the-file-manager-in-hostinger\/#h-try-the-hostinger-file-manager\">File Manager<\/a> or <a data-click-id=\"hgr-post-content-link-ftp\" href=\"\/support\/4480505-how-to-connect-to-your-hosting-using-ftp-in-hostinger\/\">FTP<\/a>.<\/li>\n<li>The fix applies to websites using PHP with either <strong>mysqli<\/strong> or <strong>PDO<\/strong> to connect to MySQL. It doesn\u2019t apply to WordPress websites.<\/li>\n<\/ul>\n<h2 id=\"h-switch-a-custom-php-website-to-persistent-mysql-connections\">Switch a custom PHP website to persistent MySQL connections<\/h2>\n<p>You need to locate the file in your website&#8217;s code that handles the database connection. This is typically named &#8220;config.php&#8221;, &#8220;db.php&#8221;, &#8220;connect.php&#8221;, &#8220;database.php&#8221;, or similar.<\/p>\n<h3>Option 1 \u2013 If your site uses mysqli<\/h3>\n<p>Find the line that looks like this:<\/p>\n<pre class=\"p1\">mysqli_connect(\"localhost\", $user, $pass, $db);<\/pre>\n<p>Change &#8220;localhost&#8221; to &#8220;p:localhost&#8221;:<\/p>\n<pre class=\"p1\">mysqli_connect(\"<strong>p:<\/strong>localhost\", $user, $pass, $db);<\/pre>\n<p>The &#8220;p:&#8221; prefix tells PHP to use a persistent connection, keeping it open across requests instead of creating a new one each time.<\/p>\n<h3>Option 2 \u2013 If your site uses PDO<\/h3>\n<p>Find the line that looks like this:<\/p>\n<pre class=\"p1\">new PDO(\"mysql:host=localhost;dbname=$db\", $user, $pass);<\/pre>\n<p>Add &#8220;[PDO::ATTR_PERSISTENT =&gt; true]&#8221; as a fourth argument:<\/p>\n<pre class=\"p1\">new PDO(\"mysql:host=localhost;dbname=$db\", $user, $pass, <strong>[PDO::ATTR_PERSISTENT =&gt; true]<\/strong>);<\/pre>\n<p>Click <strong>Deploy<\/strong> in the top-right corner to make the changes live, then reload your website.<\/p>\n<p>After making this change, your website will reuse the existing MySQL connection instead of opening a new one on every request. This keeps your connection count within Hostinger&#8217;s rate limits and resolves the &#8220;Operation not permitted&#8221; error. Your database credentials and all other settings remain unchanged.<\/p>\n<h2 id=\"h-fix-the-mysql-operation-not-permitted-error-on-a-wordpress-website\">Fix the MySQL \u201cOperation not permitted\u201d error on a WordPress website<\/h2>\n<p>WordPress doesn\u2019t support persistent MySQL connections. Adding <code>p:<\/code> to <code>DB_HOST<\/code> in <code>wp-config.php<\/code> doesn\u2019t work, because WordPress reads the text after the colon as a port. To keep a WordPress website under the limit of 20 new MySQL connections per second, reduce the number of requests that reach PHP and MySQL:<\/p>\n<ul>\n<li>Turn on page caching in the LiteSpeed Cache plugin. Cached pages load without opening a database connection.<\/li>\n<li>Turn on a content delivery network (CDN), such as <a data-click-id=\"hgr-post-content-link-hostinger-cdn\" href=\"https:\/\/www.hostinger.com\/support\/how-hostinger-cdn-caching-works\/\">Hostinger CDN<\/a>, so more visits are served from cache.<\/li>\n<li>Replace WP-Cron with a server cron job. Add <code>define('DISABLE_WP_CRON', true);<\/code> to <code>wp-config.php<\/code>, then <a data-click-id=\"hgr-post-content-link-create-a-cron-job\" href=\"https:\/\/www.hostinger.com\/support\/1583465-how-to-set-up-a-cron-job-at-hostinger\/\">create a cron job<\/a> in Hostinger dashboard that runs <code>wp-cron.php<\/code> every 5 minutes.<\/li>\n<li>Deactivate plugins that run frequent background tasks or heavy database queries, one at a time, and check whether the error stops.<\/li>\n<\/ul>\n<p>If your website needs more than 20 new MySQL connections per second during normal traffic, move it to a VPS plan, where this limit doesn\u2019t apply.<\/p>\n<p><strong>NOTES<\/strong><\/p>\n<ul>\n<li>This fix does not require any changes to your database credentials or database name.<\/li>\n<li>If you use Joomla or a framework with its own database layer, the connection file location may differ. Check its documentation for how to enable persistent database connections.<\/li>\n<li>If the error persists after applying the fix, contact Hostinger support for further assistance.<\/li>\n<\/ul>\n<p><strong>Other common database issues<\/strong><\/p>\n<p>If you&#8217;re running into a different database-related problem, see:<\/p>\n<ul>\n<li><a data-click-id=\"hgr-post-content-link-what-to-do-if-the-database-size-limit-has-been-reached-in-ho\" href=\"\/support\/5534251-what-to-do-if-the-database-size-limit-has-been-reached-in-hostinger\/\">What to do if the database size limit has been reached in Hostinger<\/a><\/li>\n<li><a data-click-id=\"hgr-post-content-link-how-to-fix-the-max_connections_per_hour-mysql-error\" href=\"\/support\/4274567-how-to-fix-the-max_connections_per_hour-mysql-error-at-hostinger\/\">How to fix the max_connections_per_hour MySQL error<\/a><\/li>\n<li><a data-click-id=\"hgr-post-content-link-how-to-fix-the-mysql-1064-error\" href=\"\/support\/1583555-how-to-fix-the-mysql-1064-error-at-hostinger\/\">How to fix the MySQL 1064 error<\/a><\/li>\n<li><a data-click-id=\"hgr-post-content-link-how-to-fix-the-user-already-has-more-than-max_user_connectio\" href=\"\/support\/1583511-how-to-fix-the-user-already-has-more-than-max-user-connections-error-at-hostinger\/\">How to fix the &#8220;User already has more than max_user_connections&#8221; error<\/a><\/li>\n<li><a data-click-id=\"hgr-post-content-link-how-to-fix-the-mysql-server-has-gone-away-error\" href=\"\/support\/1583503-how-to-fix-the-mysql-server-has-gone-away-error-at-hostinger\/\">How to fix the &#8220;MySQL server has gone away&#8221; error<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If your website is showing a database connection error such as: PHP Fatal error: Uncaught mysqli_sql_exception: Operation not permitted Connection failed: Operation not permitted ERROR:&#8230;<\/p>\n","protected":false},"author":599,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_content_updated_date":"","include_on_kodee":true,"footnotes":""},"categories":[160],"tags":[],"class_list":["post-11068","post","type-post","status-publish","format-standard","hentry","category-mysql-databases"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/how-to-fix-mysql-operation-not-permitted-error","default":1}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/11068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/599"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=11068"}],"version-history":[{"count":17,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/11068\/revisions"}],"predecessor-version":[{"id":25775,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/11068\/revisions\/25775"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=11068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=11068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=11068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}