# Error while deleting upstream

**URL:** <https://discuss.konghq.com/t/error-while-deleting-upstream/3155>\
**Category:** General\
**Created:** [April 1, 2019, 6:00am UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155 "2019-04-01T06:00:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![atul](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@atul](https://discuss.konghq.com/u/atul)\
**Post date:** [April 1, 2019, 6:00am UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/1 "2019-04-01T06:00:07Z")

</div>

Hi,

I have downloaded and installed Kong community 1.1.0 version and whenever I am trying to delete the upstream, it throws below error.

**HTTP/1.1 400 Bad Request**  
{“message”:“an existing ‘targets’ entity references this ‘upstreams’ entity”,“name”:“foreign key violation”,“fields”:{"@referenced\_by":“targets”},“code”:4}

Similar issue existed in previous community versions(1.0.3) . I saw that they have given a patch and resolved the issue in the GitHub Kong 1.0.3 source code but it still exists in Kong community 1.1.0 deb release.

Can anyone help and let me know how to fix it .

---

<div class="post-metadata">

**Author:** ![hutchic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hutchic/32/122_2.png) [@hutchic](https://discuss.konghq.com/u/hutchic)\
**Post date:** [April 1, 2019, 3:27pm UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/2 "2019-04-01T15:27:07Z")

</div>

I can’t seem to reproduce this using Kong 1.1.0 w\ postgres via docker-compose

```auto
export KONG_DOCKER_TAG=kong:1.1.0
docker-compose up -d

http POST localhost:8001/services name=service name=example-service url=http://mockbin.org

http POST localhost:8001/upstreams name=mockbin.org

http POST localhost:8001/upstreams/mockbin.org/targets target=mockbin.org

http DELETE localhost:8001/upstreams/mockbin.org
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Mon, 01 Apr 2019 15:22:56 GMT
Server: kong/1.0.3

http GET localhost:8001/upstreams/
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 23
Content-Type: application/json; charset=utf-8
Date: Mon, 01 Apr 2019 15:23:10 GMT
Server: kong/1.0.3

{
    "data": [],
    "next": null
}

```

---

<div class="post-metadata">

**Author:** ![atul](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@atul](https://discuss.konghq.com/u/atul)\
**Post date:** [April 3, 2019, 11:14am UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/3 "2019-04-03T11:14:15Z")

</div>

Thanks for the response. There seems to be some issue with the configurations. I restarted kong and it started working.

---

<div class="post-metadata">

**Author:** ![hutchic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hutchic/32/122_2.png) [@hutchic](https://discuss.konghq.com/u/hutchic)\
**Post date:** [April 3, 2019, 11:39am UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/4 "2019-04-03T11:39:52Z")

</div>

Any details about the configurations you can provide to try and reproduce?

---

<div class="post-metadata">

**Author:** ![atul](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@atul](https://discuss.konghq.com/u/atul)\
**Post date:** [April 3, 2019, 12:21pm UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/5 "2019-04-03T12:21:04Z")

</div>

I performed below steps:

1. Installed Kong 1.0.3 which has this issue.

2. Installed Kong 1.1 on top of Kong 1.0.3

3. Ran kong migrations up

4. Then until I restarted kong, I had the issue.

Thanks

---

<div class="post-metadata">

**Author:** ![hutchic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hutchic/32/122_2.png) [@hutchic](https://discuss.konghq.com/u/hutchic)\
**Post date:** [April 3, 2019, 3:25pm UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/6 "2019-04-03T15:25:11Z")

</div>

I can’t seem to reproduce it in 1.0.3 and I can’t reproduce it when I update a 1.0.3 install to a 1.1.1 installation

```auto
export KONG_DOCKER_TAG=kong:1.0.3
docker-compose up -d

http POST localhost:8001/services name=service name=example-service url=http://mockbin.org
http POST localhost:8001/upstreams name=mockbin.org
http POST localhost:8001/upstreams/mockbin.org/targets target=mockbin.org
http DELETE localhost:8001/upstreams/mockbin.org
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Wed, 03 Apr 2019 15:21:11 GMT
Server: kong/1.0.3

http POST localhost:8001/upstreams name=mockbin.org
http POST localhost:8001/upstreams/mockbin.org/targets target=mockbin.org

export KONG_DOCKER_TAG=kong:1.1.1
docker-compose up -d

http localhost:8001/upstreams
http localhost:8001/upstreams/mockbin.org/targets
http DELETE localhost:8001/upstreams/mockbin.org
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Wed, 03 Apr 2019 15:24:12 GMT
Server: kong/1.1.1

```

---

<div class="post-metadata">

**Author:** ![atul](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@atul](https://discuss.konghq.com/u/atul)\
**Post date:** [April 3, 2019, 3:38pm UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/7 "2019-04-03T15:38:28Z")

</div>

Can you please try installing Kong via 1.0.3 deb file instead of docker.

Thanks

Atul

---

<div class="post-metadata">

**Author:** ![hutchic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hutchic/32/122_2.png) [@hutchic](https://discuss.konghq.com/u/hutchic)\
**Post date:** [April 5, 2019, 9:36pm UTC](https://discuss.konghq.com/t/error-while-deleting-upstream/3155/8 "2019-04-05T21:36:48Z")

</div>

The debian and docker assets are functionally identical as they’re built from the same code, installed into a temporary directory and then packages into a .deb / tag.gz.

I also haven’t seen similar bug reports to this. When Kong fails to delete the upstream is there anything relevant in Kong / postgres logs?
