Sync postgresql table on own host not allowed

Trying to create a table with “Sync PostgreSQL table” method, but it says " It’s not allowed to connect to this hostname" when I specify the same host it is selfhosted on, even if with a different username. It rejects other domain names pointed to the same server IP too. Other hosts seem to be accepted, but fail as I don’t have login details. Is there a restriction on using the same host as Baserow itself uses?

Hey @andrisi

Sorry to hear that you have trouble with using “Sync PostgreSQL table”

How did you setup your postgresql connection?

As our sync sources documentation says you need to provide:

Server hostname: The address of your PostgreSQL server.
Username: The username used to access the database.
Password: The corresponding password for the specified username.
Database name: The name of the database containing the table you want to synchronize.
Schema name: The schema within the database where the table resides.
Table name: The exact name of the PostgreSQL table you wish to synchronize.
Port number: The port number used by the PostgreSQL server (default is 5432).
SSL mode: The desired SSL mode for the connection (e.g., ‘disable’, ‘verify-ca’, ‘require’).

to be able to connect.

Yes by default Baserow doesn’t allow to connect to the very same PostgreSQL database it runs on. You should be able to disable it by setting BASEROW_PREVENT_POSTGRESQL_DATA_SYNC_CONNECTION_TO_DATABASE environment variable to some falsy value (anything that is not “1”, “true”, etc.)

1 Like

Thanks @petrs I added that variable, and now it works!

Unfortunately it fails miday with a " Something went wrong during the sync_data_sync_table job execution. Create and sync table" on the UI and “SSL connection has been closed unexpectedly” - on a million row table after running for a few minutes, just as with an external PSQL server. Others have that isseue at Error: psycopg2.OperationalError: SSL connection has been closed unexpectedly

Thanks @Przemek I set all these. Whatever alternative hostname to my server I tried, it said the same about that server. Other servers, with all the same required params are working. Now it’s an SSL timeout. The log shows the single line below, and the UI says “Sync error: It’s not allowed to connect to this hostname.”

2024-12-11T15:12:03.207307504Z [BACKEND][2024-12-11 15:12:03] WARNING 2024-12-11 15:12:03,206 django.request.log_response:241- Bad Request: /api/database/data-sync/properties/

Unfortunately I think the Baserow implementation of the table sync from PostgreSQL is not really written in large tables in mind currently. I am sure you are facing some database limits and the connection gets closed automatically by the database or in transit because Baserow tries to fetch all table rows at once.

I created an issue for it here: Improve PostgreSQL table data sync for large tables (#3288) · Issues · Baserow / baserow · GitLab

1 Like