# Error 500, port is already allocated

**URL:** <https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604>\
**Category:** ShinyProxy\
**Created:** [July 5, 2018, 7:18am UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604 "2018-07-05T07:18:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahalasz](https://support.openanalytics.eu/letter_avatar_proxy/v4/letter/a/bbe5ce/32.png) [@ahalasz](https://support.openanalytics.eu/u/ahalasz)\
**Post date:** [July 5, 2018, 7:18am UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/1 "2018-07-05T07:18:55Z")

</div>

Hi,

We have several Shiny apps deployed with Shinyproxy, which works great. However, from time to time all apps stop working with the attached error. ![shinyproxy_error](https://support.openanalytics.eu/uploads/default/original/1X/e1a2c95324d2fe93c2624b7754b21244ed50be63.PNG)

We don’t know why all apps try to open on the same port in this case. The solution we found is to restart shinyproxy.

The docker settings in the application.yml are:  
docker:  
cert-path: /home/none  
url: [http://localhost:2375](http://localhost:2375)  
host: 127.0.0.1  
port-range-start: 40000

I would say that this happens, on average, once or twice a month.

Would you have an idea why this strange behaviour?

Thank you,  
Andrei

---

<div class="post-metadata">

**Author:** ![fmichielssen](https://support.openanalytics.eu/user_avatar/support.openanalytics.eu/fmichielssen/32/1088_2.png) [@fmichielssen](https://support.openanalytics.eu/u/fmichielssen)\
**Post date:** [July 5, 2018, 8:44am UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/2 "2018-07-05T08:44:44Z")

</div>

Hi @ahalasz,

If this is happening, ShinyProxy assumes port 40007 is available, but it’s not.  
This could either be another application allocating the port, or a previous proxy not shutting down correctly.

If it happens again, you can try a `docker ps` or a `netstat -tln` to find out who is using the port.

---

<div class="post-metadata">

**Author:** ![ahalasz](https://support.openanalytics.eu/letter_avatar_proxy/v4/letter/a/bbe5ce/32.png) [@ahalasz](https://support.openanalytics.eu/u/ahalasz)\
**Post date:** [July 5, 2018, 4:44pm UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/3 "2018-07-05T16:44:47Z")

</div>

Hi,

Thank you for your quick answer. I just had again the same behaviour, saying that port 40007 is already allocated. The `docker ps` command is showing that no container is using that port (see attached). ![docker_ps](https://support.openanalytics.eu/uploads/default/original/1X/99c6e46b80c510da9ef7effb56b0657609182ba6.PNG)

However, the `netstat -tln` command is showing that something is listening on port 40007 but I don’t know what.

Active Internet connections (only servers)  
Proto Recv-Q Send-Q Local Address Foreign Address State  
tcp 0 0 0.0.0.0:40000 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40001 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40002 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40003 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40004 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40005 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40006 0.0.0.0:\* LISTEN  
tcp 0 0 0.0.0.0:40007 0.0.0.0:\* LISTEN

---

<div class="post-metadata">

**Author:** ![ahalasz](https://support.openanalytics.eu/letter_avatar_proxy/v4/letter/a/bbe5ce/32.png) [@ahalasz](https://support.openanalytics.eu/u/ahalasz)\
**Post date:** [July 13, 2018, 12:19pm UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/4 "2018-07-13T12:19:53Z")

</div>

Further investigation suggested that an exited Docker container is still using port 40007. What is interesting is that is seems to always be port 40007 that is causing the issue.

---

<div class="post-metadata">

**Author:** ![czeildi](https://support.openanalytics.eu/user_avatar/support.openanalytics.eu/czeildi/32/315_2.png) [@czeildi](https://support.openanalytics.eu/u/czeildi)\
**Post date:** [October 3, 2019, 8:00am UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/5 "2019-10-03T08:00:29Z")

</div>

Hi,

we are experiencing similar issue, sometimes we get `Bind for 0.0.0.0:\(.*\) failed: port is already allocated.` errors but we cannot reproduce it on demand. Killing the container which somehow did not shut down correctly solves the issue but requires manual intervention. Even automating killing these containers is not very user friendly: on the first try they get an error.

Do you know what is the root cause for this behavior?

regards,  
Ildi

---

<div class="post-metadata">

**Author:** ![Deril\_Raju](https://support.openanalytics.eu/user_avatar/support.openanalytics.eu/deril_raju/32/780_2.png) [@Deril\_Raju](https://support.openanalytics.eu/u/Deril_Raju)\
**Post date:** [January 16, 2023, 11:06pm UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/6 "2023-01-16T23:06:43Z")

</div>

Is there any solution to this problem?

---

<div class="post-metadata">

**Author:** ![spinanicky](https://support.openanalytics.eu/user_avatar/support.openanalytics.eu/spinanicky/32/879_2.png) [@spinanicky](https://support.openanalytics.eu/u/spinanicky)\
**Post date:** [September 19, 2023, 2:34pm UTC](https://support.openanalytics.eu/t/error-500-port-is-already-allocated/604/7 "2023-09-19T14:34:27Z")

</div>

After restarting shinyproxy with no users - I noticed that there were several 200\*\* ports occupied. So I bumped up the min port to 40000 in the config and that seems to have worked.
