I am using the magento version 2.0.9 version for my site.

I am getting this Url key for specified store is already exist while updating the product or assigning the product for custom option and click on Save button.

I have deleted all entries in URL rewrite table in the database also. But I am still getting this error while updating any product.

Any idea for this error?


7 Answers 7


I came here searching for a similar issue but with Category save. So when I tried to save the category it threw same error "URL key for specified store already exists.".

After debugging by removing the try..catch block at insertMultiple() method of Magento\UrlRewrite\Model\Storage\DbStorage. I identified that while saving the category Magento was trying to re-build url rewrites for assigned products also. And few products had same url_key and that was throwing duplicate records error. As url_rewrite table has a UNIQUE contraint on request_path, store_id columns.

See exception.log to find out the url_key that is creating issue.

So I just made the url_key unique for products and that resolved the issue.

Hope these debugging steps may prove helpful to somebody who stumbles here again.

  • 1
    This saved me a huge headache!! Thank you. In my case I had a handful of unique products that had identical names that were tossing this issue that I didn't even think about. Also when creating configurable products keep in mind the request_path needs to be unique for each simple product.
    – Vallier
    Commented Jun 29, 2017 at 15:48

In admin Products -> categories

Please check there is a space before "Default Category"

like this:

" Default Category"

click on that and remove space before Default Category after that import you CSV file.

Also Check for different category has same category url

Like this :

Inside a Search Engine Optimization tab change url is it 's same as a different category url

it will work.

  • Oh man you save my day
    – AbdulBasit
    Commented Nov 22, 2022 at 6:33

First find the which table use for product data insert

Second find product which record id zero and replace increment id for record in table Hope it will work for you


I faced the same issue and the isue is solved now by truncating the "url_rewrite" table from database.But it is not always a better solution to truncate the table and generate the urls.However the small change in the code in "doReplace" method of Magento\UrlRewrite\Model\Storage\DbStorage will do it for us. As it is a core file I have extended the file in my custom module as below, the di.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\UrlRewrite\Model\Storage\DbStorage" type="Custom\UrlRewrite\Model\DbStorage"/>

then comes our extended file

namespace Custom\UrlRewrite\Model;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;

class DbStorage extends \Magento\UrlRewrite\Model\Storage\DbStorage {

    protected function doReplace($urls) {

        foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData) {
            $urlData[UrlRewrite::ENTITY_TYPE] = $type;
        $data = [];
        $storeId_requestPaths = [];
        foreach ($urls as $url) {
            $storeId = $url->getStoreId();
            $requestPath = $url->getRequestPath();
            // Skip if is exist in the database
            $sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
            $exists = $this->connection->fetchOne($sql);

            if ($exists)

            $storeId_requestPaths[] = $storeId . '-' . $requestPath;
            $data[] = $url->toArray();

        // Remove duplication data;
        $n = count($storeId_requestPaths);
        for ($i = 0; $i < $n - 1; $i++) {
            for ($j = $i + 1; $j < $n; $j++) {
                if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j]) {


for reference I have got the answer from this post
hope it helps...

  • I have apply this solution and category save issue fixed. But new updated url key not updated in front menu. Do you have any idea then let me know. Commented Mar 8, 2021 at 7:04

I had this problem with 2 products that had the same name in the same category. Magento was trying to create an identical URL key to the other product and was failing. After changing one product name to something else, it worked.


I found that in addition to clearing any entries in the URL_rewrite I found that any indexing must be completed as well. BTW: I limited the deletion as follows:

Delete from url_rewrite where entity_type = 'category'

  • 1
    Do NOT delete url_rewrite unless you want all of your menu's to no longer work. Re-indexing does not rebuild these urls, so you manually have to re-save them to get the url paths to work again, plus any categories that are having this error, will still have them but now won't be able to be re-saved. I tried this, and had to perform a DB restore to undo this simple "fix" Commented Jan 31, 2017 at 18:10
  • Well If you reindex your menu will not break, just the url's will not be nicely formatted
    – tread
    Commented Feb 17, 2017 at 9:41
  • didn't work for me. Commented Apr 20, 2017 at 16:22

Issue is resolved by deleting the entries from "url_rewrite" table from database..After deleting the entries from table,then assign category to the products and click on save button.

You can easily assign the categories to the products.

  • 1
    As Spyrule says above, do NOT do this (without a backup)! Category URLs will not be rebuilt if you remove them from the url_rewrite table.
    – James
    Commented Jul 6, 2017 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.