Skip to main content

Changing PostgreSQL Port

Overview

This document is about the products used in demilitarization.**PostgreSQL default port (5432)**This document provides guidance on how to change __PH_0__ to align with customer policies.

If you change the PostgreSQL port, the configuration files of the services that connect to the DB must also reflect the changed port.


Basic Information

itemvalue
Default Port5432
Change Example15432
Target ServicePostgreSQL
Impact ServiceApache Tomcat 10.1 CDR_SERVICE_UPLOAD
Apache Tomcat 10.1 CDR_SERVICE_API
Apache Tomcat 9.0 CDR_WEBCONSOLE
Product basic DB configuration file pathE:\softcamp\DB\PostgreSQL\data\postgresql.conf
Service configuration file pathE:\softcamp\sanitrans\sanitrans\config\cdrbroker.properties
E:\softcamp\sanitrans\sanitrans\config\WebConsoleApi.properties

Port Change Procedure

Step 1: Modify the PostgreSQL configuration file

Configuration file path:E:\softcamp\DB\PostgreSQL\data\postgresql.conf

If the DB is on a separate server (Linux)

DB service isSeparate Linux servereven if built on**under the installation path (data directory)postgresql.conf**You can modify it.

// Generally, postgresql.conf is located under $PGDATA (data directory).
// For example: /var/lib/pgsql/data/postgresql.conf or /var/lib/postgresql/<version>/main/postgresql.conf

Change Items

60Change the following item near line __PH_0__.

# PostgreSQL 서버 포트
port = 5432

Change example:

# PostgreSQL 서버 포트
port = 15432

Step 2: Restart PostgreSQL Service

After saving the configuration file, restart the PostgreSQL service.

  • Windows Service Manager(services.msc) inPostgreSQLRestart the service

You can also restart in PowerShell (according to the environment).

# PowerShell 관리자 권한으로 실행
# NOTE: 서비스 이름은 설치 환경에 따라 다를 수 있습니다.
Get-Service | Where-Object { $_.DisplayName -like "*PostgreSQL*" }

# 예시(서비스 이름 확인 후 사용)
# Restart-Service "postgresql-x64-16"
// Changing the PostgreSQL port will not take effect until after a restart.

If the DB is on a separate server (Linux)

On a Linux server,postgresql.confRestart the PostgreSQL service after modification (the service name may vary depending on the distribution/installation method).

# systemd 기반(예시) - 환경에 맞게 사용
# sudo systemctl restart postgresql
# sudo systemctl restart postgresql-16
# sudo systemctl restart postgresql@16-main

# 상태 확인
# sudo systemctl status postgresql

Step 3: Modify the Impact Service Configuration File

If you change the PostgreSQL port, the service settings that connect to the DB must also reflect the same port.

3-1) CDR_SERVICE_UPLOAD / CDR_SERVICE_API: cdrbroker.properties

Configuration file path:E:\softcamp\sanitrans\sanitrans\config\cdrbroker.properties

postgresql.portis port settings.

  • postgresql.portaChange the value only if it exists
  • postgresql.portaAdd new if not presentEnter the port after changing

Example:

# PostgreSQL 포트 설정
postgresql.port=15432

3-2) CDR_WEBCONSOLE: WebConsoleApi.properties

Configuration file path:E:\softcamp\sanitrans\sanitrans\config\WebConsoleApi.properties

dbserver.portis port settings.

  • dbserver.portaChange the value only if it exists
  • dbserver.portaAdd new if not presentEnter the port after changing

Example:

# PostgreSQL 포트 설정
dbserver.port=15432

Step 4: Restart Impact Service

After saving the configuration file, restart the services in the following order:

  1. Apache Tomcat 10.1 CDR_SERVICE_UPLOAD
  2. Apache Tomcat 10.1 CDR_SERVICE_API
  3. Apache Tomcat 9.0 CDR_WEBCONSOLE

How to Restart Windows Services

# PowerShell 관리자 권한으로 실행
Restart-Service "Apache Tomcat 10.1 CDR_SERVICE_UPLOAD"
Restart-Service "Apache Tomcat 10.1 CDR_SERVICE_API"
Restart-Service "Apache Tomcat 9.0 CDR_WEBCONSOLE"

or Windows Service Manager(services.msc) will restart sequentially.


Configuration Validation

Normal operation check

  1. Check if all services have started normally
  2. Decontamination Test Execution
  3. Monitoring Log Check

Port Listening Check (Optional)

# 변경한 포트(예: 15432) 리스닝 여부 확인
netstat -ano | findstr :15432

Caution

Symptoms when settings are not applied (Important)

PostgreSQL port has been changed, but the service configuration file (cdrbroker.properties, WebConsoleApi.propertiesIf the port is not reflected, the following DB connection failure log may occur.

Log Check Path: E:\log\cdrApiService\cdrApiService.log

Error log example:

2026-02-11 14:46:47.252 ERROR [                  main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: Connection to 127.0.0.1:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Cause:

  • PostgreSQL is running on the changed port, but
  • Impact service is still on the default port5432Connection attempt to __PH_0__ was refused.

Solution:

  1. cdrbroker.propertiesofpostgresql.portCheck if it is set to the changed port.
  2. WebConsoleApi.propertiesofdbserver.portCheck if it is set to the changed port.
  3. Restart in the order of Impact Service (UPLOAD → API → WEBCONSOLE)

Reference Notes

  • Changing ports is recommended to be performed during times of low system load.
  • Backup of current settings recommended before changes
  • If there is a firewall configuration, it is necessary to add firewall rules for the new port.
  • Pre-check if another application is using the specified port.