diff --git a/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb b/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
index 0551577284e4325e922812adc98e699892f45486_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvYXR0cmlidXRlcy9kZWZhdWx0LnJi..072e8bdecfd7492e12e7dabd71ede01b8fece8f3_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvYXR0cmlidXRlcy9kZWZhdWx0LnJi 100644
--- a/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
+++ b/files/gitlab-cookbooks/gitlab-ee/attributes/default.rb
@@ -66,7 +66,7 @@
 default['gitlab']['geo_secondary']['db_password'] = nil
 default['gitlab']['geo_secondary']['db_load_balancing'] = { 'hosts' => [] }
 # Path to postgresql socket directory
-default['gitlab']['geo_secondary']['db_host'] = "/var/opt/gitlab/geo-postgresql"
+default['gitlab']['geo_secondary']['db_host'] = nil # when `nil` - value is set from geo_postgresql['dir']
 default['gitlab']['geo_secondary']['db_port'] = 5431
 default['gitlab']['geo_secondary']['db_socket'] = nil
 default['gitlab']['geo_secondary']['db_sslmode'] = nil
diff --git a/files/gitlab-cookbooks/gitlab-ee/libraries/geo_secondary.rb b/files/gitlab-cookbooks/gitlab-ee/libraries/geo_secondary.rb
index 0551577284e4325e922812adc98e699892f45486_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvbGlicmFyaWVzL2dlb19zZWNvbmRhcnkucmI=..072e8bdecfd7492e12e7dabd71ede01b8fece8f3_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvbGlicmFyaWVzL2dlb19zZWNvbmRhcnkucmI= 100644
--- a/files/gitlab-cookbooks/gitlab-ee/libraries/geo_secondary.rb
+++ b/files/gitlab-cookbooks/gitlab-ee/libraries/geo_secondary.rb
@@ -5,6 +5,7 @@
   class << self
     def parse_variables
       parse_database
+      parse_geo_secondary_db_host
     end
 
     def node
@@ -45,4 +46,22 @@
       node['gitlab']['geo_secondary'].to_h.keys.select { |k| k.start_with?('db_') }
     end
 
+    def parse_geo_secondary_db_host
+      return unless geo_secondary_enabled? && geo_database_enabled?
+
+      db_host = Gitlab['gitlab_rails']['databases']['geo']['db_host']
+      if db_host&.include?(',')
+        Gitlab['gitlab_rails']['databases']['geo']['db_host'] = db_host.split(',')[0]
+        warning = [
+          "Received multiple geo_secondary['db_host'] values: #{db_host.to_json}.",
+          "First listen_address '#{Gitlab['gitlab_rails']['databases']['geo']['db_host']}' will be used."
+        ].join("\n  ")
+        warn(warning)
+      end
+
+      # In case no other setting was provided for db_host,
+      # we use the socket directory
+      Gitlab['gitlab_rails']['databases']['geo']['db_host'] ||= Gitlab['geo_postgresql']['unix_socket_directory']
+    end
+
     def geo_database_enabled?
@@ -48,5 +67,5 @@
     def geo_database_enabled?
-      Gitlab['gitlab_rails']['databases']['geo']['enable'] == true
+      Gitlab['gitlab_rails'].dig('databases', 'geo', 'enable') == true
     end
   end
 end
diff --git a/spec/chef/cookbooks/gitlab-ee/recipes/geo-secondary_spec.rb b/spec/chef/cookbooks/gitlab-ee/recipes/geo-secondary_spec.rb
index 0551577284e4325e922812adc98e699892f45486_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWItZWUvcmVjaXBlcy9nZW8tc2Vjb25kYXJ5X3NwZWMucmI=..072e8bdecfd7492e12e7dabd71ede01b8fece8f3_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWItZWUvcmVjaXBlcy9nZW8tc2Vjb25kYXJ5X3NwZWMucmI= 100644
--- a/spec/chef/cookbooks/gitlab-ee/recipes/geo-secondary_spec.rb
+++ b/spec/chef/cookbooks/gitlab-ee/recipes/geo-secondary_spec.rb
@@ -288,6 +288,7 @@
   context 'when geo_secondary_role is enabled but geo-postgresql is disabled' do
     before do
       stub_gitlab_rb(geo_secondary_role: { enable: true },
+                     geo_secondary: { db_host: '/var/opt/gitlab/geo-postgresql' },
                      geo_postgresql: { enable: false })
     end
 
@@ -304,6 +305,40 @@
 
   context 'when geo_secondary_role is enabled' do
     before do
+      stub_gitlab_rb(geo_secondary_role: { enable: true },
+                     geo_postgresql: { enable: true, dir: '/tmp/geo-postgresql' })
+    end
+
+    it 'sets geo-secondary db_host to the value of geo_postgresql socket directory ' do
+      expect(database_yml[:production][:geo][:host]).to eq('/tmp/geo-postgresql')
+    end
+  end
+
+  context 'when geo_secondary_role is enabled and geo_secondary db_host is set' do
+    before do
+      stub_gitlab_rb(geo_secondary_role: { enable: true },
+                     geo_secondary: { db_host: '/some_test_directory/geo-postgresql' },
+                     geo_postgresql: { enable: true, dir: '/tmp/geo-postgresql' })
+    end
+
+    it 'sets geo-secondary db_host to the specified db_host' do
+      expect(database_yml[:production][:geo][:host]).to eq('/some_test_directory/geo-postgresql')
+    end
+  end
+
+  context 'when geo_secondary_role is enabled, and geo-postgresql is enabled, but geo-postgresql dir is not set' do
+    before do
+      stub_gitlab_rb(geo_secondary_role: { enable: true },
+                     geo_postgresql: { enable: true })
+    end
+
+    it 'sets geo-secondary db_host to the default' do
+      expect(database_yml[:production][:geo][:host]).to eq('/var/opt/gitlab/geo-postgresql')
+    end
+  end
+
+  context 'when geo_secondary_role is enabled' do
+    before do
       stub_gitlab_rb(geo_secondary_role: { enable: true })
 
       # Make sure other calls to `File.symlink?` are allowed.