Postgresql – Administrator can’t view tables (“server refused to connect”)

pgadmin-4postgresql

I'm quite experienced with MSSQL and MySQL/MariaDB, but I'm a newbie re PostgreSQL.

I got everything to work, except for the odd detail that the admin user which I set up during installation can't "view/edit" tables. The error displayed is:

domain.com refused to connect

Here's what works

I installed PostgreSQL 12.3 and pgAdmin4 both on a Ubuntu 20.04 LTS server (Azure VM, CLI only, no GUI). Everything works, I can log in from a browser (domain.com/pgadmin4), and create databases and tables.

This doesn't seem to work

However, when I right-click on a table (View/edit data -> first 100 rows), then I get the error message:

domain.com refused to connect.

Equally strange observation

Also, on another machine, I use Pentaho Data Integration for ETL purposes. From there, I can connect, create tables (via the automatic SQL code it generates), and I can both write and read tables, not a problem at all.

Problem

My only issue is that the admin user in pgAdmin4 cannot read tables (despite the "Administrator" role). I also turned off ufw (the Ubuntu Firewall), and any IP restrictions in the Azure account (which is effectively a second firewall). I also checked the logfile postgresql-12-main.log, but I didn't see any related entries.

I'd really appreciate if someone could give me an idea how to troubleshoot that.

Best Answer

I figured it out, I needed to add two lines in the ssl.conf file:

Header set Access-Control-Allow-Origin "*"

Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"

That solved it (don't forget to restart apache).

Related Question