All Products
Search
Document Center

ApsaraDB RDS:Configure the firewall of a server

Last Updated:Mar 28, 2026

Before using the cloud migration feature to migrate data from a self-managed PostgreSQL instance to ApsaraDB RDS for PostgreSQL, open the PostgreSQL port on the server firewall so that the migration service can connect to the source database.

The steps in this topic apply to CentOS. For other operating systems, refer to the official documentation for that OS.

Prerequisites

Before you begin, ensure that you have:

  • Access to the server on which the self-managed PostgreSQL instance runs

  • Root or sudo privileges on the server

Open the PostgreSQL port

The default PostgreSQL port is 5432. If your instance uses a different port, replace 5432 with the actual port number in the commands below.

CentOS 7

  1. Connect to the server.

  2. Check which ports are currently open:

    firewall-cmd --list-ports
  3. Open TCP port 5432 to allow inbound connections from the migration service:

    firewall-cmd --zone=public --add-port=5432/tcp --permanent
  4. Reload the firewall to apply the change:

    firewall-cmd --reload
  5. Confirm the port is now listed as open:

    firewall-cmd --list-ports

    The output should include 5432/tcp.

CentOS 6 or earlier

  1. Connect to the server.

  2. Check which ports are currently open:

    /etc/init.d/iptables status
  3. Open port 5432 to allow inbound TCP connections:

    /sbin/iptables -I INPUT -p tcp --dport 85432 -j ACCEPT
  4. Restart the firewall to apply the change:

    service iptables restart

Alternative: disable the firewall

If opening a specific port is not practical, you can disable the firewall before the migration.

Warning

Disabling the firewall exposes the server to all inbound traffic. Re-enable it after the migration is complete.

  • CentOS 7:

    systemctl stop firewalld.service
  • CentOS 6 or earlier:

    service iptables stop

What's next

Use the cloud migration feature