diff --git src/wp-includes/post.php src/wp-includes/post.php
index 620d1e4..4ffd487 100644
--- src/wp-includes/post.php
+++ src/wp-includes/post.php
@@ -3673,7 +3673,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
 
 	if ( 'attachment' == $post_type ) {
 		// Attachment slugs must be unique across all types.
-		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
+		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_status != 'auto-draft' post_name = %s AND ID != %d LIMIT 1";
 		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
 
 		/**
