admin管理员组

文章数量:1277901

I'm trying to configure PyCharm's Data Source tool to use a locally running postgres database (not in a container) and it simply fails with the (not very helpful) message "[08001] The connection attempt failed."

I can connect to it in the shell with the command psql -hlocalhost -p5432 -Umac1 lib1. Also the code I wrote in PyCharm has no problem accessing it, with psycopg.connect("dbname=lib1").

I added the data source in the "Data Sources and Drivers" dialog and edited the information accordingly. For "Authentication" I chose "User & Password", set "User" to "mac1", and "Password" to what I set in psql with "ALTER USER mac1 WITH PASSWORD". The URL I get is jdbc:postgresql://localhost:5432/lib1, which seems correct to me. But PyCharm fails to connect. I also tried turning on/off SSL but that didn't help.

The postgresql server version I'm using is 16.3, and PyCharm is using postgresql driver ver 42.7.3.

本文标签: pythonPyCharm cannot connect to local postgresql databaseStack Overflow