# Fail to rebuild and got 502 Bad Gateway

**URL:** <https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390>\
**Category:** Self-hosting\
**Created:** [August 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:** 1\
**Showing post:** 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:** [August 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.

---

_[View the full topic](https://meta.discourse.org/t/fail-to-rebuild-and-got-502-bad-gateway/68390)._
