How to fix ERROR 1202: Could not create slave thread; check system resources in MySQL

MySQLINTERMEDIATEHIGHUpdated Dec 23, 2025ยท 180 views

MySQL error 1202 stops replication when the system cannot create slave threads. This typically indicates insufficient memory, thread limits, or other resource constraints. Resolve by checking system resources, adjusting ulimit settings, or restarting the replication process.

Quick fix

Fixes ERROR 1202: Could not create slave thread; check system resources

SHOW SLAVE STATUS\G
  1. Check current replication status
  2. Check system memory usage
  3. Check system thread and file descriptor limits
  4. Stop replication and restart the slave
mysql โ€” error
SHOW SLAVE STATUS\G
ERROR 1202: Could not create slave thread; check system resources

What this error means

ERROR 1202 (ER_SLAVE_THREAD) occurs when MySQL replication fails because the system cannot allocate resources to create a replica thread. This error indicates that the slave (now called replica in MySQL 8.0+) thread has stopped and needs to be restarted. The error message explicitly tells you to "check system resources," which typically means the server is running low on memory, threads are exhausted, or system limits are preventing thread creation. In MySQL 8.0.33+, this error was renamed from ER_SLAVE_THREAD to ER_REPLICA_THREAD with the updated message "Could not create replica thread; check system resources," but the underlying cause remains the same.

Typical symptoms

  • Replication suddenly stops working between master and slave servers
  • Replica_IO_Running or Replica_SQL_Running shows as "No" in SHOW SLAVE STATUS
  • Error log contains "ERROR 1202: Could not create slave thread"
  • Application fails to read from slave database causing data inconsistency
  • Performance degradation as slave server becomes out of sync
  • Replication cannot be restarted until system resources are available

Common causes

  1. Server memory is exhausted or nearly full, preventing thread allocation
  2. System ulimit settings restrict thread creation (ulimit -u or ulimit -m)
  3. Too many existing database connections consuming available threads
  4. Insufficient virtual memory or swap space
  5. OS-level limits on process resource usage (e.g., FreeBSD maxdsiz)
  6. Replication memory overhead from processing large transactions or row-based logs
  7. Previous replication thread did not properly clean up resources

How to fix "ERROR 1202: Could not create slave thread; check system resources"

1Check current replication status

Connect to the slave server and verify its current state:

sql
SHOW SLAVE STATUS\G

Look for the values of Slave_IO_Running and Slave_SQL_Running. If either is "No", replication has stopped. Check the Last_Error field for the exact error message.

2Check system memory usage

Verify that the server has sufficient available memory:

bash
free -h
# or on macOS
vm_stat

Also check MySQL memory allocation:

sql
SHOW GLOBAL STATUS LIKE 'max_used_connections';
SHOW GLOBAL VARIABLES LIKE 'max_connections';

If memory usage is above 85-90% of available RAM, you need to free up resources or add more memory.

3Check system thread and file descriptor limits

On Linux, verify ulimit settings for the mysqld process:

bash
# Check current limits for the MySQL process
cat /proc/$(pidof mysqld)/limits

# Or check as the mysql user
ulimit -a

Key limits to check:
- max user processes: Should be higher than max_connections (default 151)
- open files: Should be at least 65535

If limits are too low, increase them by editing /etc/security/limits.conf:

bash
mysql soft nofile 65535
mysql hard nofile 65535
mysql soft nproc 65535
mysql hard nproc 65535

Then restart MySQL.

4Stop replication and restart the slave

Once resources are available, restart the replication process:

sql
-- Stop the slave
STOP SLAVE;

-- Clear the relay logs
RESET SLAVE;

-- If needed, reconfigure replication
CHANGE MASTER TO
  MASTER_HOST='master_host',
  MASTER_USER='replication_user',
  MASTER_PASSWORD='password',
  MASTER_LOG_FILE='mysql-bin.000001',
  MASTER_LOG_POS=154;

-- Start the slave
START SLAVE;

-- Verify status
SHOW SLAVE STATUS\G

Wait a moment and check the status again to ensure both Slave_IO_Running and Slave_SQL_Running are "Yes".

5Adjust MySQL thread stack size if needed

If increasing system limits doesn't resolve the issue, reduce MySQL's thread stack memory usage:

sql
SHOW GLOBAL VARIABLES LIKE 'thread_stack';

The default is usually 262144 bytes (256KB). If memory is still constrained, you can reduce this in your MySQL configuration file:

ini
[mysqld]
thread_stack = 192K

Then restart MySQL. Note: Only reduce this if you're experiencing stack overflow errors; too low a value can cause crashes.

6Monitor and maintain healthy replication

To prevent this error from recurring:

1. Regularly monitor replication status: Set up automated checks for SHOW SLAVE STATUS

2. Monitor system resources: Use tools like htop, Prometheus, or your cloud provider's monitoring

3. Set replication alerts: Configure MySQL to alert when Seconds_Behind_Master exceeds a threshold

4. Plan capacity: Ensure your slave has at least as much memory as the master

5. Use parallel replication (MySQL 5.7+): Enable multithreaded replication for better performance:

sql
STOP SLAVE;
SET GLOBAL slave_parallel_workers = 4;
SET GLOBAL slave_parallel_type = 'LOGICAL_CLOCK';
START SLAVE;

However, on low-resource systems, reduce parallel workers or set to 0.

Advanced notes

For MySQL 8.0.33+, note that the error symbol changed from ER_SLAVE_THREAD to ER_REPLICA_THREAD with updated message text, but troubleshooting is identical. If you're using row-based replication (RBR) with large transactions, MySQL 5.6.21+ and 5.7.5+ fixed a memory leak where virtual temporary tables weren't freed mid-transaction. If you're on an older version and replicating massive transactions, upgrade to a patched version. On AWS RDS, if experiencing replication errors, try disabling multithreaded replication by setting replica_parallel_workers to 0. In container/Docker environments, ensure the MySQL container has sufficient memory allocation (--memory flag or docker-compose limits) and that the host has adequate swap configured.

Frequently asked questions

What does "ERROR 1202: Could not create slave thread; check system resources" mean?
ERROR 1202 (ER_SLAVE_THREAD) occurs when MySQL replication fails because the system cannot allocate resources to create a replica thread. 0+) thread has stopped and needs to be restarted. The error message explicitly tells you to "check system resources," which typically means the server is running low on memory, threads are exhausted, or system limits are preventing thread creation.
How do I fix "ERROR 1202: Could not create slave thread; check system resources"?
MySQL error 1202 stops replication when the system cannot create slave threads. This typically indicates insufficient memory, thread limits, or other resource constraints. Resolve by checking system resources, adjusting ulimit settings, or restarting the replication process.
What causes "ERROR 1202: Could not create slave thread; check system resources"?
Server memory is exhausted or nearly full, preventing thread allocation System ulimit settings restrict thread creation (ulimit -u or ulimit -m) Too many existing database connections consuming available threads
Is the "ERROR 1202: Could not create slave thread; check system resources" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading