Skip to main content

Changing PostgreSQL Port

Overview

This document is about products used in demilitarization.**PostgreSQL default port (5432)**This document provides guidance on how to change it to align with the client's policy.

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

When the DB is on a separate server (Linux)

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

// 일반적으로 postgresql.conf는 $PGDATA(데이터 디렉터리) 하위에 위치합니다.
// 예: /var/lib/pgsql/data/postgresql.conf 또는 /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) inPostgreSQLRestarting the service

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

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

# 예시(서비스 이름 확인 후 사용)
# Restart-Service "postgresql-x64-16"
// PostgreSQL 포트 변경은 재시작 전에는 반영되지 않습니다.

When the DB is on a separate server (Linux)

On a Linux server,postgresql.confRestart the PostgreSQL service after making changes (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.portThis is the port configuration.

  • postgresql.portaChange value only if it exists
  • postgresql.portaAdd new if not presentEnter the port changed afterwards

Example:

# PostgreSQL 포트 설정
postgresql.port=15432

3-2) CDR_WEBCONSOLE: WebConsoleApi.properties

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

dbserver.portThis is the port configuration.

  • dbserver.portaChange value only if it exists
  • dbserver.portaAdd new if not presentEnter the port changed afterwards

Example:

# PostgreSQL 포트 설정
dbserver.port=15432

Step 4: Restart Impact Service

After saving the configuration file, restart the service 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. Performing Decontamination Test
  3. Check Monitoring Logs

Check Port Listening (Optional)

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

Cautions

Symptoms when settings are not applied (Important)

Changed the PostgreSQL port, 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 a changed port, but
  • The 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)

Notes

  • It is recommended to perform port change operations during times of low system load.
  • It is recommended to back up the current settings before making changes.
  • If there is a firewall configuration, it is necessary to add firewall rules for the new port.
  • Check in advance if another application is using the port.