SSHTunnelForwarder ( ( '' ), ssh_username = 'your PythonAnywhere username', ssh_password = 'the password you use to log in to the PythonAnywhere website', remote_bind_address = ( 'your PythonAnywhere database hostname, eg.
Your Postgres database, you can install the sshtunnel packageĪnd then use code like this: import psycopg2 import sshtunnel sshtunnel. If you're running Python code on your local machine, and you want it to access
If you're using TablePlus, you can use the settings from this diagram provided by Then you should be able to connect from pgAdmin to your PythonAnywhere Postgres Sure to use the correct port in the next step.Īnd give the connection a name on the "General" tab, then set up the stuff on theĪny user you have set up on your Postgres server, eg. You can try any other port number greater than 1024 and less than 65536. If that doesn't work because you get an error like: cannot listen to port: 9999 The local side of your SSH tunnel will be at port 9999. As long as that SSH session is active, your SSH tunnel When this has worked, it will appear that you have SSHed into your The port from the Postgres tab of the "Databases" page inside PythonAnywhere Your PythonAnywhere database hostname, eg. Tunnel from your machine to PythonAnywhere and then connect to the local portįirst, we create the SSH tunnel: ssh -4 -L 9999:postgres-server-hostname:postgres-server-port you should: replace If you're running pgadmin, you can use SSH in a local terminal to create an SSH There are a number of ways to do this: pgAdmin ¶