find postgresql.conf file #port=5432 change into port="whatever you want" ex)port=3542 (uncomment) restart postgresql
refer : https://sqlserverguides.com/restart-postgres/
You can check all os system like mac,window, etc.