Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tariqul9ict's avatar

Error on Hostinger Shared Hosting: "Can't create more than max_prepared_stmt_count statements"

Description:
I deployed my Laravel application on Hostinger shared hosting, and everything runs fine locally. However, after deployment, I'm getting the following database error:

SQLSTATE[42000]: Syntax error or access violation: 1461 Can't create more than max_prepared_stmt_count statements (current value: 100000)

From what I understand, this error is related to the maximum number of prepared statements allowed by the MySQL server. Since I’m on shared hosting, I don’t have permission to increase the max_prepared_stmt_count setting manually.

Things I’ve tried:

  • Running php artisan config:cache and php artisan route:cache
  • Making sure I’m not using unnecessary loops or raw queries
  • Reviewing queries to ensure there’s no resource leakage

Despite these steps, the issue persists.

Has anyone else faced this issue on Hostinger or other shared hosting environments? Is there a Laravel-specific workaround or optimization I can apply to avoid hitting this limit?

Any help would be greatly appreciated!

0 likes
4 replies
manish-sharmaa's avatar

Hi,

try this: SET GLOBAL max_prepared_stmt_count = 200000;

It will fix your problem.

tariqul9ict's avatar

@manish-sharmaa Thank you for your response.

I use shared hosting. I am unable to increase max_prepared_stmt_count value. Also codeIgniter appplication run smoothly in same hosting. But laravel application throw this error

Jsanwo64's avatar

It means your MySQL server has reached the maximum allowed number of prepared statements (max_prepared_stmt_count), which is currently set to 100,000.

two things could trigger this error according to my search on the error;

  1. You're not closing prepared statements (often happens with raw queries or loops),

  2. You're using persistent connections without cleanup,

Jsanwo64's avatar

Can you give an example of what you have for

Making sure I’m not using unnecessary loops or raw queries
Reviewing queries to ensure there’s no resource leakage

for review purpose

Please or to participate in this conversation.