If your server is hosting a website on the Internet and running a database system on the same machine, it is safer to disable remote network access to the database. On the other hand, you may still want to manage your databases remotely. You can do so by tunneling PostgreSQL traffic over an SSH connection.
Note
One of the most important aspects of a database system is the speed with which it can find and return the data that you ask for. Tunneling traffic over SSH will add significant overhead to this communication. This solution is great for intermittent management tasks, but not suitable as a replacement for a direct connection to your database system.