Question: psql how to connect to remote database?
Answer: Open a terminal window and type the following command at the command line. Replace username with your A2 Hosting username, and replace example.com with your site's domain name: ssh -p 7822 username@example.com -L 5432:localhost:5432. ... 
Type your password, and then press Enter.