Forums

Unable to connect PostgreSQL db to pgAdmin 4: Connection Refused

I've been following this guide: Accessing your PostgreSQL database from outside PythonAnywhere

I was able to create the SSH tunnel, but upon entering the pgAdmin 4 settings, it get an error which says: "channel 2: open failed: Connection refused." The "server dialog" hyperlink goes to a 404 page so I'm not certain if I've entered the required details, that said, the username and password are correct.

Any help would be much appreciated as I've been stuck on this for quite a while. Please see the following image for more info:

Unable to connect to pgAdmin 4

The port number you have for your Postgres instance does not look right.

Thanks for the reply. Yeah, I tried a few ports greater than 1024 and less than 65536, as suggested by the guide.

You should use the port that is shown in your PA Postgres settings, see https://help.pythonanywhere.com/pages/AccessingPostgresFromOutsidePythonAnywhere/.

Thanks for the reply, I used the Postgres port however I got an error as it doesn't seem associated with localhost. Please see below.

I was able to get the database connected to TablePlus which is a... plus.

enter image description here

Oh my I am a tad slow today.

The ssh command has the port as 0112 instead of 10112. It's connected now.

Thanks for your help.

Glad to hear that you made it work!