502 error in gitlab after another application started using postgres

I have gitlab installed with default postgres db and it was working fine until I had to install another ALM tool for which postgres was bundled along with it but its installed in different path. So now I have 2 postgres setup but I have configured both of them to a different port but still I am unable to open the gitlab as I am getting 502 error with "Whoops, GitLab is taking too much time to respond" .

Please find the output of the command $sudo gitlab-ctl tail unicorn

==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
E, [2019-09-03T17:33:28.047856 #20275] ERROR -- : adding listener failed addr=127.0.0.1:8080 (in use)
E, [2019-09-03T17:33:28.047963 #20275] ERROR -- : retrying in 0.5 seconds (4 tries left)
E, [2019-09-03T17:33:28.549091 #20275] ERROR -- : adding listener failed addr=127.0.0.1:8080 (in use)
E, [2019-09-03T17:33:28.549304 #20275] ERROR -- : retrying in 0.5 seconds (3 tries left)
E, [2019-09-03T17:33:29.050605 #20275] ERROR -- : adding listener failed addr=127.0.0.1:8080 (in use)
E, [2019-09-03T17:33:29.050778 #20275] ERROR -- : retrying in 0.5 seconds (2 tries left)
E, [2019-09-03T17:33:29.551638 #20275] ERROR -- : adding listener failed addr=127.0.0.1:8080 (in use)
E, [2019-09-03T17:33:29.551781 #20275] ERROR -- : retrying in 0.5 seconds (1 tries left)
E, [2019-09-03T17:33:30.052684 #20275] ERROR -- : adding listener failed addr=127.0.0.1:8080 (in use)
E, [2019-09-03T17:33:30.052855 #20275] ERROR -- : retrying in 0.5 seconds (0 tries left)
E, [2019-09-03T17:33:30.553731 #20275] ERROR -- : adding listener failed addr=127.0.0.1:8080 (in use)

==> /var/log/gitlab/unicorn/unicorn_stdout.log <==
bundler: failed to load command: unicorn (/opt/gitlab/embedded/bin/unicorn)

==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
Errno::EADDRINUSE: Address already in use - bind(2) for 127.0.0.1:8080
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/socket_helper.rb:164:in `bind'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/socket_helper.rb:164:in `new_tcp_server'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/socket_helper.rb:144:in `bind_listen'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:241:in `listen'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:851:in `block in bind_new_listeners!'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:851:in `each'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:851:in `bind_new_listeners!'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:140:in `start'
  /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `<top (required)>'
  /opt/gitlab/embedded/bin/unicorn:23:in `load'
  /opt/gitlab/embedded/bin/unicorn:23:in `<top (required)>'

==> /var/log/gitlab/unicorn/current <==
2019-09-03_12:03:30.59723 master failed to start, check stderr log for details
2019-09-03_12:03:31.60724 failed to start a new unicorn master
2019-09-03_12:03:31.64104 starting new unicorn master

It looks like the problem is not postgres (which runs on port 5432 by default), but unicorn which is trying to listen to traffic on port 8080. It says there is another process using that port.

I suggest looking at that first.

Agree with you, I am able to open gitlab after killing the process on 8080 , But i have changed the unicorn port to 8282 so not sure why it needs 8080. I have updated in gitlab.rb file i hope that is sufficient for unicorn to run on different port . can someone guide me if any other files need to be updated as well ?

issue got fixed after changing the port in postgres and restarting the server

1 Like