# נכשל בשחזור וקיבל שגיאה 502 Bad Gateway

**URL:** https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390
**Category:** Self-hosting
**Created:** [19 באוגוסט,‏ 2017,‏ 5:42pm UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390 "2017-08-19T17:42:10Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![xiasummer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xiasummer/32/82790_2.png) [@xiasummer](https://meta.discourse.org/u/xiasummer)
#### Post date: [19 באוגוסט,‏ 2017,‏ 5:42pm UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/1 "2017-08-19T17:42:10Z")

</div>

with error info

```plaintext
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle install --deployment --verbose --without test --without development' failed with return #<Process::Status: pid 359 exit 7>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
5d1ddc450c71623db162884cdd854e23d9108eb10a45ba3b12833491667ede2a
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one

```

As it said I should read the former lines for more error messages, I checked the message in **./launcher rebuild app** and found the only more message is

```plaintext
2017-08-20 04:27:13.878 UTC [56] postgres@postgres ERROR: database "discourse" already exists
2017-08-20 04:27:13.878 UTC [56] postgres@postgres STATEMENT: CREATE DATABASE discourse;
createdb: database creation failed: ERROR: database "discourse" already exists
I, [2017-08-20T04:27:13.880744 #15] INFO -- :
I, [2017-08-20T04:27:13.881052 #15] INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2017-08-20 04:27:13.966 UTC [67] postgres@discourse ERROR: role "discourse" already exists
2017-08-20 04:27:13.966 UTC [67] postgres@discourse STATEMENT: create user discourse;
ERROR: role "discourse" already exists

```

And here is the docker ps that might help.

```plaintext
 docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f8b075b4656b sameersbn/gitlab:latest "/sbin/entrypoint...." 3 months ago Up 21 minutes 443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp gitlab_gitlab_1
d2dd063db080 sameersbn/redis:latest "/sbin/entrypoint...." 11 months ago Up 21 minutes 6379/tcp gitlab_redis_1
e875efc4b0b5 sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 11 months ago Up 21 minutes 5432/tcp gitlab_postgresql_1

```

* * *

**Could you please help me？**

* * *

I checked meta, and found some perhaps similar answers, but I tried rebooted the server, and nothing happened.

> [@\[Solved\]Bootstrap fails, Postgres already running](https://meta.discourse.org/t/solved-bootstrap-fails-postgres-already-running/20041):
>
> Hi, I’m attempting to install Discourse, but am failing so far. It appears that bootstrapping doesn’t want to… bootstrap? Anyhow, I read a couple of other threads about it and tried “./launcher rebuild app”, which gave the following output: WARNING: No memory limit support WARNING: No swap limit support Updating discourse docker Already up-to-date. Calculated ENV: -e LANG=en\_US.UTF-8 -e RAILS\_ENV=production -e UNICORN\_WORKERS=3 -e UNICORN\_SIDEKIQS=1 -e RUBY\_GC\_MALLOC\_LIMIT=40000000 -e RUBY\_HE…

* * *

Is it because this is a server in China, and now some of the websites are blocked by the great Chinese firewall?

* * *

## What’s more

It’s not only not rebuildable, but also the server encounters 502 Badgateway(nginx) error.

I checked the docker is running.

I restarted the discourse, rebooted the server, but still nothing happened.

---

<div class="post-metadata">

### Author: ![xiasummer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xiasummer/32/82790_2.png) [@xiasummer](https://meta.discourse.org/u/xiasummer)
#### Post date: [20 באוגוסט,‏ 2017,‏ 4:23am UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/2 "2017-08-20T04:23:48Z")

</div>

Any one can help? It’s quite urgent.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [20 באוגוסט,‏ 2017,‏ 6:10am UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/3 "2017-08-20T06:10:53Z")

</div>

The rebuild command produces a lot of output. You have not included it all, or enough to say where the problem may lay.

Checking, I see my last failed rebuild had 280 lines of output.

---

<div class="post-metadata">

### Author: ![xiasummer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xiasummer/32/82790_2.png) [@xiasummer](https://meta.discourse.org/u/xiasummer)
#### Post date: [20 באוגוסט,‏ 2017,‏ 12:52pm UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/4 "2017-08-20T12:52:32Z")

</div>

Hi, you asked for the whole message

[total\_message.txt.gz](https://global.discourse-cdn.com/meta/original/3X/5/6/56c76096d1a4609f8b9fe6b8dd8112e55522715e.gz) (46.9 KB)

@codinghorror

and I found a very similar problem which was caused by the source of ruby china.

> [@Failed to rebuild Discourse with the following information](https://meta.discourse.org/t/failed-to-rebuild-discourse-with-the-following-information/48386):
>
> ./launcher rebuild app returns: FAILED -------------------- Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle install --deployment --verbose --without test --without development' failed with return #\<Process::Status: pid 312 exit 7\> Location of failure: /pups/lib/pups/exec\_command.rb:108:in `spawn' exec failed with the params {"cd"=\>"$home", "hook"=\>"bundle\_exec", "cmd"=\>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discours…

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [20 באוגוסט,‏ 2017,‏ 1:47pm UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/5 "2017-08-20T13:47:19Z")

</div>

Line 2584 in your log file:

> Your bundle is locked to message\_bus (2.0.5), but that version could not be  
> found in any of the sources listed in your Gemfile. If you haven’t changed  
> sources, that means the author of message\_bus (2.0.5) has removed it. You’ll  
> need to update your bundle to a different version of message\_bus (2.0.5) that  
> hasn’t been removed in order to install.

So you’re correct that this is caused by the RubyGem mirror you’re using.

* * *

Running the following should remove the bundler mirror config.

```plaintext
bundle config --delete mirror.https://rubygems.org

```

[Here is](http://bundler.io/v1.15/bundle_config.html#MIRRORS-OF-GEM-SOURCES) the official doc on using mirrors with bundler.

---

<div class="post-metadata">

### Author: ![xiasummer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xiasummer/32/82790_2.png) [@xiasummer](https://meta.discourse.org/u/xiasummer)
#### Post date: [20 באוגוסט,‏ 2017,‏ 3:42pm UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/6 "2017-08-20T15:42:00Z")

</div>

Thank you very much. I got all the problems done with the help of a Chinese friend.

That is because of the ruby source in China is not up to date.

And the solving is delete the line in app.yml

![image](https://global.discourse-cdn.com/meta/original/3X/9/5/95c2e5d7f5d0de424256da277bf98e41b01bd722.png)

Rebuild you will solve such problems.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8 ביוני,‏ 2024,‏ 12:44pm UTC](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390/7 "2024-06-08T12:44:24Z")

</div>

This topic was automatically closed after 2484 days. New replies are no longer allowed.
