diff --git a/2.Common_services/3.PostgreSQL/0_setup.py b/2.Common_services/3.PostgreSQL/0_setup.py
index 6a22701e5ef060073db2296cf31d914da1306565..0411cb0804c756588abecbf7443c12e41e5bb51e 100644
--- a/2.Common_services/3.PostgreSQL/0_setup.py
+++ b/2.Common_services/3.PostgreSQL/0_setup.py
@@ -5,8 +5,9 @@ import utils
 
 def setup(interactive=True):
     db_host = utils.get_conf('DB_HOST')
-    if db_host and not db_host.startswith('127') and db_host != 'localhost':
-        utils.log('Skipping postgresql setup because the database host is set to "%s".' % db_host)
+    db_port = utils.get_conf('DB_PORT')
+    if (db_host and not db_host.startswith('127') and db_host != 'localhost') or db_port != 5432:
+        utils.log('Skipping postgresql setup because the database host is set to "%s:%i".' % (db_host, db_port))
         return
     cmds = [
         'DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql',