Common SQL Errors

MySQL Error 1135: ER_CANT_CREATE_THREAD - Causes, Fixes, and Prevention

Galaxy Team
August 5, 2025

MySQL cannot spawn a new operating system thread because the host has exhausted process or memory limits, triggering error 1135.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1135 (ER_CANT_CREATE_THREAD)?

MySQL Error 1135: ER_CANT_CREATE_THREAD occurs when MySQL fails to create a new OS thread due to hitting system thread, PID, or RAM limits. Free server memory, raise ulimit -n/-u, or tune innodb_thread_concurrency to resolve the issue.

Error Highlights

Typical Error Message

Can't create a new thread (errno %d); if you are not out

Error Type

Resource Error

Language

MySQL

Symbol

ER_CANT_CREATE_THREAD

Error Code

1135

SQL State

Explanation

Table of Contents

What is MySQL error 1135 (ER_CANT_CREATE_THREAD)?<\/h2>

Error 1135 fires when the MySQL server asks the operating system for a new thread but the OS refuses. The accompanying message usually reads: "Can't create a new thread (errno XX); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug."<\/p>

The server fails to accept new client connections or spawn background workers.

High-traffic production databases often see this during load spikes, mis-configured limits, or memory leaks. Rapid mitigation is critical or the instance becomes unresponsive.<\/p>.

What Causes This Error?<\/h3>

Operating systems enforce limits on the total number of processes or threads a user can own. When mysqld reaches that ceiling, any further pthread_create call fails, surfacing error 1135.<\/p>

Memory starvation can also trigger the error. If mysqld cannot allocate stack space for the thread, the OS denies the request even if thread counts remain below the limit.<\/p>

Mis-tuned MySQL variables such as thread_cache_size or innodb_thread_concurrency may exacerbate the condition by keeping idle threads alive.<\/p>

How to Fix MySQL Error 1135<\/h3>

Immediate relief is freeing resources: close idle client sessions, kill runaway queries, or restart the instance during a maintenance window. Long-term fixes require raising OS limits or lowering MySQL concurrency settings.<\/p>

Check per-user thread limits with ulimit -a<\/code> on Linux or review maxproc<\/code>/maxthreads<\/code> on macOS. Increase values in /etc/security/limits.conf<\/code> or systemd service files, then restart MySQL.<\/p>

On Windows, confirm the server is not hitting non-interactive desktop heap limits; a reboot may be required.<\/p>

Common Scenarios and Solutions<\/h3>

High connection spikes:<\/strong> Use connection pooling or set max_connections<\/code> to a sustainable value. Galaxy’s pooled query runner prevents client storms from overwhelming MySQL.<\/p>

Memory leaks:<\/strong> Profile RAM usage with pmap<\/code> or valgrind<\/code>. Upgrade to a patched MySQL version if leaks stem from known bugs.<\/p>

Docker limits:<\/strong> Ensure the container has adequate --pids-limit<\/code> and memory allocations. Amend compose files and redeploy.<\/p>

Best Practices to Avoid This Error<\/h3>

Set OS thread and open-file limits well above peak demand. Automate checks with Prometheus or CloudWatch to alert when mysqld thread count nears 80% of the ceiling.<\/p>

Configure thread_cache_size<\/code> to reuse threads instead of spawning new ones. For OLTP workloads, values between 16 and 64 balance reuse and memory overhead.<\/p>

Galaxy helps by centralizing SQL execution. Fewer developers open ad-hoc sessions, reducing simultaneous connections and preventing thread exhaustion.<\/p>

Related Errors and Solutions<\/h3>

MySQL Error 1203 - ER_TOO_MANY_USER_CONNECTIONS: Similar symptom but triggered at the MySQL layer instead of the OS. Lower max_user_connections<\/code> or pool connections.<\/p>

MySQL Error 1040 - ER_CON_COUNT_ERROR: Fires when max_connections is exceeded. Increase the variable or apply connection pooling.<\/p>

MySQL Error 2002 - Can't connect to local MySQL server: Appears when the server stops accepting sockets, often following 1135. Reboot or free resources.<\/p>

Common Causes

Operating system thread or process limits reached<\/h3>Linux defaults often cap user processes (ulimit -u) at 1024. Busy servers reach this quickly, blocking new threads.<\/p>

Memory exhaustion<\/h3>Each thread needs stack memory.

Low available RAM or over-commit settings make the kernel deny allocations.<\/p>

Misconfigured MySQL concurrency settings<\/h3>Large thread pools without proper cache eviction keep idle threads alive, inflating counts unnecessarily.<\/p>

Buggy plugins or storage engines<\/h3>Third-party audit or replication plugins may leak threads or block their cleanup, hitting limits over time.<\/p>.

Related Errors

FAQs

Does increasing max_connections fix error 1135?<\/h3>No. The failure occurs at the operating system level, not MySQL. Raising the limit can worsen the problem.<\/p>

How do I check my thread limit on Linux?<\/h3>Run ulimit -a in the shell that starts mysqld. Look for "max user processes".<\/p>

Can Galaxy stop thread exhaustion?<\/h3>Yes. Galaxy pools queries and reuses sessions, reducing simultaneous client threads hitting MySQL.<\/p>

Is a server restart required?<\/h3>Only if memory or thread handles cannot be freed. Properly killing idle sessions often resolves the issue without downtime.<\/p>

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo