diff --git a/etherpad/templates/settings.json.j2 b/etherpad/templates/settings.json.j2
index 1f16796c94bd5ce8218fffdaf2962c43f9027182..f383d67c28935dd5d343d3c237e002b559e6d639 100644
--- a/etherpad/templates/settings.json.j2
+++ b/etherpad/templates/settings.json.j2
@@ -16,10 +16,14 @@
   "dbSettings": {
     "user": "{{item.db_user}}",
     "host": "localhost",
-    "port": 3306,
     "password": "{{item.db_password}}",
-    "database": "{{item.name}}",
+    "database": "{{item.db_name}}",
+    {% if item.db_type == "mysql" %}
+    "port": 3306,
     "charset": "utf8mb4"
+    {% elif item.db_type == "postgres" %}
+    "port": 5432
+    {% endif %}
   },
 
   "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at https:\/\/etherpad.org\n",