# Restarting container when internet is down causes discourse to fail

**URL:** https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615
**Category:** Bug
**Created:** [15.Апрель.2016 15:29:13 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615 "2016-04-15T15:29:13Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![carbo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carbo/32/54170_2.png) [@carbo](https://meta.discourse.org/u/carbo)
#### Post date: [15.Апрель.2016 15:29:13 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/1 "2016-04-15T15:29:13Z")

</div>

It seems that if you have an intranet discourse site, even though it might have internet access, will no longer work if two factors come into play:

1. Your internet access is down (for whatever reason)
2. You decide to restart your discourse container during the same period.

Steps to reproduce.

1. Make a local Discourse install and configure it so that is properly setup
2. Unplug your network from the internet
3. Restart your Discourse container `./launcher stop app` then `./launcher start app`
4. Try to access the local Discourse site

After further checking.

The problem is caused by the nginx service not being able to find the host [avatars.discourse.org](http://avatars.discourse.org) found at line 220 of the discourse.conf file if the server has no internet access when trying to start. Once the internet connection is re-established nginx will start up. For that period of time your Discourse site will remain unusable. A workaround is to set line 220 of discourse.conf to:

`proxy_pass https://localhost/;`

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [15.Апрель.2016 19:50:41 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/2 "2016-04-15T19:50:41Z")

</div>

Hmm, maybe, but if you are setting up on intranet with no Internet access you should turn off the external web hosted avatars anyway in site settings.

---

<div class="post-metadata">

### Author: ![carbo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carbo/32/54170_2.png) [@carbo](https://meta.discourse.org/u/carbo)
#### Post date: [15.Апрель.2016 20:11:44 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/3 "2016-04-15T20:11:44Z")

</div>

I agree but that change will only be applied once your site is functional or can start 😆

Hopefully this will help someone having the same issue. From all my tests since, Discourse is running fine. So glad I didn’t have to resort to phpBB.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [22.Апрель.2016 01:20:37 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/4 "2016-04-22T01:20:37Z")

</div>

The issue causing this is documented here:

> <https://stackoverflow.com/questions/32845674/nginx-how-to-not-exit-if-host-not-found-in-upstream>

I would like to change it so letter avatars are all served via the rails app which can be a lot smarter about dealing with a problem DNS entry an so on.

Just blanket failing to load NGINX cause `avatars.discourse.org` is not something we can allow.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [22.Апрель.2016 03:41:25 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/5 "2016-04-22T03:41:25Z")

</div>

Wouldn’t that cause a ton of extra load?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [22.Апрель.2016 03:48:13 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/6 "2016-04-22T03:48:13Z")

</div>

We heavily cache stuff in nginx would only hit the app once per avatar

---

<div class="post-metadata">

### Author: ![Matt\_Campbell](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Matt\_Campbell](https://meta.discourse.org/u/Matt_Campbell)
#### Post date: [07.Ноябрь.2018 16:05:16 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/7 "2018-11-07T16:05:16Z")

</div>

I’ve opened two PRs to fix this:

1. [in discourse\_docker](https://github.com/discourse/discourse_docker/pull/413)
2. [in discourse](https://github.com/discourse/discourse/pull/6576)

The second depends on the first.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [07.Ноябрь.2018 21:28:00 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/8 "2018-11-07T21:28:00Z")

</div>

Thanks for that.. what do you think @sam?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [18.Февраль.2019 03:01:27 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/10 "2019-02-18T03:01:27Z")

</div>

This is fixed per:

[https://github.com/discourse/discourse/commit/f04471e4229218903df17232db955cd583a423ef](https://github.com/discourse/discourse/commit/f04471e4229218903df17232db955cd583a423ef)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18.Февраль.2019 03:46:56 UTC](https://meta.discourse.org/t/restarting-container-when-internet-is-down-causes-discourse-to-fail/42615/11 "2019-02-18T03:46:56Z")

</div>


