Common SQL Errors

MySQL Error 1021: ER_DISK_FULL - How to Fix and Prevent

Galaxy Team
August 5, 2025

MySQL Error 1021 (ER_DISK_FULL) occurs when the server cannot write to disk because the partition holding data, temporary files, or logs has no free space.

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 code 1021 (ER_DISK_FULL)?

MySQL Error 1021: ER_DISK_FULL means the server ran out of disk space while writing data or temp files. Free space on the MySQL, tmp, or log partitions, then restart or resume the transaction to resolve the issue.

Error Highlights

Typical Error Message

Disk full (%s); waiting for someone to free some space...

Error Type

Resource Error

Language

MySQL

Symbol

ER_DISK_FULL

Error Code

1021

SQL State

Explanation

Table of Contents

What does "Disk full (%s); waiting for someone to free some space..." mean?

MySQL raises Error 1021 (SQLSTATE HY000) when it attempts to write to a data file, temporary table, binary log, or InnoDB redo log but the underlying filesystem reports no available space. The server stops the current statement and waits for disk capacity to be released.

This error can appear on Linux, macOS, Windows, and cloud volumes.

It is critical to fix quickly because writes are blocked, causing application downtime and possible transaction rollbacks.

What causes MySQL Error 1021?

Insufficient free space on the data directory is the primary trigger. Large INSERT ... SELECT, ALTER TABLE, or CREATE INDEX operations can suddenly consume gigabytes in the tmpdir or InnoDB temporary files.

Binary log retention, oversized undo logs, or a runaway slow query creating massive temporary tables also fill disks.

On virtual machines, thin-provisioned storage may silently hit the provider quota and surface as ER_DISK_FULL.

How do I fix MySQL Error 1021?

First, check df -h (Linux) or disk utility to confirm which mount point is full. Remove or archive old binary logs with PURGE BINARY LOGS, truncate general/slow logs, or relocate them to a larger volume.

Increase the partition size, move the tmpdir to a disk with free space, or add a new data file to the InnoDB tablespace.

After freeing space, retry the failed statement or let transactions continue.

Common scenarios and solutions

During an ALTER TABLE ADD COLUMN, MySQL creates a full table copy in the tmpdir. Redirect tmpdir to /mnt/bigssd and rerun the command.

Large binary log retention causes disk growth. Enable expire_logs_days or binlog_expire_logs_seconds to prune automatically.

Best practices to avoid this error

Monitor disk usage with cron jobs or cloud alerts and keep at least 20 percent free. Compress and rotate logs using logrotate.

Set innodb_log_file_size appropriately for workload to avoid bloated redo logs.

Galaxy’s SQL editor integrates disk-usage checks into its AI copilot. When it detects a 1021 error in query output, it suggests immediate cleanup commands and flags the affected server in your workspace.

Related errors and solutions

MySQL Error 1114 "Table is full" occurs when the storage engine hits its size limit, not the filesystem. Error 1030 "Got error %d from storage engine" can wrap the same ENOSPC condition inside InnoDB.

Resolve them with the same free-space techniques.

.

Common Causes

Related Errors

FAQs

How much free space should I keep to prevent Error 1021?

Maintain at least 20 percent free space on data and tmpdir volumes. This buffer accommodates sudden spikes from large queries or binary logs.

Can I recover automatically after freeing space?

Yes. Once the filesystem has free blocks, MySQL resumes writes. Long transactions may need a retry if they were rolled back.

Does changing tmpdir require a restart?

Yes. tmpdir is read at startup. Modify my.cnf and restart or use symbolic links to redirect temporary files without downtime.

How does Galaxy help?

Galaxy’s AI copilot detects ER_DISK_FULL in query results, surfaces disk metrics, and proposes binlog purging or tmpdir relocation steps inside the editor.

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