Not able to connect to Anvil's Postgresql server in the tutorial

What I’m trying to do:
I am trying to follow the Anvil Tutorial on how to work with external databases. Here’s the link Anvil | Query an external database from Python

But in the very first chapter I hit a roadblock.

What I’ve tried and what’s not working:
I am trying to connect to the sample posstgresql database that Anvil provides. I have tried using psql (see screenshots) and also a DBeaver app but they are not connecting. I am using standard Port 5432 on DBeaver and username is the same as Database ID, as instructed.

Please see screenshots. Thanks.


Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Clone link:
share a copy of your app

Note – I also tried using the IP address of where it is hosted, as specified in the instructions. That did not work as well. See screenshot. Thanks.

Possible firewall issue?

I am just starting off in my Anvil plus Web app journey. I am attempting to create an app with a database and I am following the tutorial that you describe. Did you find a resolution to this issue?

I am having the same issue with Step 1: Create an external database. I am assuming that the server at one of the given IP addresses (35.177.174.19 / 18.133.244.120 which one??) is either not running or for some reason I can not access it.

This is what I get when I try to run the python script called ‘inventory.py’ based on the Tutorial :
##python script
##Import the Anvil Uplink library
import anvil.server
import psycopg2

anvil.server.connect(‘’)
#35.177.174.19
#host=“18.133.244.120”
conn = psycopg2.connect(
host=“35.177.174.19”,
user=“corny_positive_towel”,
password=“gloomy_ragged_pause”)
conn.set_session(autocommit=True)

cur = conn.cursor()

@anvil.server.callable
def get_items():
cur.execute(‘SELECT id, item_name, quantity FROM inventory;’)
items = cur.fetchall()
return [
{‘id’: item[0], ‘name’: item[1], ‘quantity’: item[2]}
for item in items
]

anvil.server.wait_forever()

##And the output is

Connecting to wss://anvil.works/uplink
Anvil websocket open
Connected to “Default environment” as SERVER
Traceback (most recent call last):
File “C:/Users/tom/Desktop/Projects/PythonCode/inventory.py”, line 9, in
conn = psycopg2.connect(
File “C:\Users\tom\AppData\Local\Programs\Python\Python311\Lib\site-packages\psycopg2_init_.py”, line 122, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at “35.177.174.19”, port 5432 failed: Connection timed out (0x0000274C/10060)
Is the server running on that host and accepting TCP/IP connections?

You might want to try bit.io for a free hosted third party Postgres implementation.

Also, if it’s at all useful, I converted tutorial example above to run with sqlite, using uplink: Learn the Python Anvil Framework

Thank you for the time to respond. My apologies for not thanking you sooner. Thanks in particular for the link to the sqlite solution. It was my intention to eventually connect to sql. However, I was hoping initially to follow the tutorials as presented by Anvil and by a process of some form of osmosis, get a good understanding of the various technologies. I have listened to a few podcasts (‘The Real Python Podcast’) where the original founder Meredydd talks about Anvil and the reasons for developing it. All very interesting. I have dabbled a little with Javascript and nodejs without too much success. This seems like a good solution for what I want to do at the moment.