---
title: "How to Fix Unique Constraint Violation Found in Magento 2"
url: "https://dolphinwebsolution.com/how-to-fix-unique-constraint-violation-found-in-magento-2"
date: "2021-10-07T04:24:14+05:30"
modified: "2023-10-19T08:53:43+05:30"
author:
  name: "Jigar Patel"
categories:
  - "Magento"
word_count: 398
reading_time: "2 min read"
summary: "While saving a new product in the admin panel I am getting this error \"Unique constraint violation found\"

Magento 2.4.3 installation and save the product on that time not able to add any product..."
description: "While saving a new product in the admin panel I am getting this error \"Unique constraint violation found\". here we will explain how to solve this error."
keywords: "Unique Constraint Violation Found,fix Unique Constraint Violation Found,Unique Constraint Violation Found in magento 2,Unique Constraint Violation Found in magento, Magento"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to get store config values by scope in Magento 2"
    url: "https://dolphinwebsolution.com/how-to-get-store-config-values-by-scope-in-magento-2"
  - title: "How to Add Custom Block to Order View Information in Magento"
    url: "https://dolphinwebsolution.com/add-custom-block-to-order-view-information-in-magento"
  - title: "Top 10 Reasons to Why You Should Choose Magento for eCommerce"
    url: "https://dolphinwebsolution.com/magento-for-ecommerce-top-10-reasons-as-to-why-you-should-choose-it"
---

# How to Fix Unique Constraint Violation Found in Magento 2

_Published: October 7, 2021_  
_Author: Jigar Patel_  

![](https://dolphinwebsolution.com/wp-content/uploads/2023/02/Constraint-Violation-1-1024x536.png)

While saving a new product in the admin panel I am getting this error **“Unique constraint violation found”**

Magento 2.4.3 installation and save the product on that time not able to add any products, categories items to it. I get an error “Unique constraint violation found” when I do any of these operations. I was able to [add custom product attributes ](https://dolphinwebsolution.com/add-custom-select-options-attribute-in-category-form-magento-2)and add them to attribute sets too, but am stuck after that.

You may have got an integrity constraint violation error while creating a product from the backend in [Magento 2 store](https://dolphinwebsolution.com/shop/).

When you face this error, it means that a **duplicate value** is created in the database table.

**In this blog you will find the solution of unique constraint violation found in magento 2 :**

Unique Constraint Violation error usually occurs when adding data to a database table. The reason for the error can be the creation of duplicate values in the database table.

Here’s the solution to **fix unique constraint violation in Magento 2** admin panel.

### How to Fix Unique Constraint Violation Found in Magento 2
### Solution:1
Table ‘**catalog\_product\_entity**‘ last inserted row id is “349580” (highest) but in table **AUTO\_INCREMENT** value is “338897” so **Exception occur.**

Probably your **AUTO\_INCREMENT** is set wrong for the table. You can check this with:

**SELECT `AUTO\_INCREMENT` FROM INFORMATION\_SCHEMA.TABLES WHERE TABLE\_SCHEMA = ‘db\_name’ AND TABLE\_NAME = ‘table\_name’;**

You can then fix the auto-increment by setting it the highest **ID +1**

**ALTER TABLE table\_name AUTO\_INCREMENT = start\_value;**

![AI Integration in Magento: Benefits, Use Cases and Business Impact](https://dolphinwebsolution.com/wp-content/uploads/2021/10/product-save-1024x347.png)

### Solution:2
Face **“Unique Constraint violation found”** issue in invoice check bellow step:

SOLVED Invoice Unique Constraint Violation Magento 2.2.5 when i am generating a invoice facing this error

Just go to **data base -> sales\_invoice -> indexes** just remove one rule **“SALES\_INVOICE\_INCREMENT\_ID\_STORE\_ID**

### Solution:3
Face **“Unique Constraint violation found”** issue in creating a new order check bellow step:

Check the table “**sequence\_order\_1**” where 1 refers to the store id.

The sequence\_value column should be ***auto\_increment*** to fix the integrity constraint violation in Magento 2.

That’s it this is how you can easily fix **Unique Constraint Violation** errors in Magento 2, All the given 3 scenarios are easy to implement

If you have any difficulties regarding this blog, do consider posting in the Comments section below! If you are looking for an [**expert Magento developer**](https://dolphinwebsolution.com/hire-magento-2-developers/) then you can contact us.

I’m here to help.

**Thank you!**


---

_View the original post at: [https://dolphinwebsolution.com/how-to-fix-unique-constraint-violation-found-in-magento-2](https://dolphinwebsolution.com/how-to-fix-unique-constraint-violation-found-in-magento-2)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-26 07:39:11 UTC_  
