0

i simply cannot connect pgadmin to the postgresql running on local host!

i followed the official Ubuntu document for setting postgres up. i can also access the db through terminal easily by using: psql --host localhost --username <user_name> --password -p 5433 --dbname <db_name> the error generated by the pgadmin interface is this: (https://i.stack.imgur.com/dQBxz.png)

while the above mentioned command in terminal executes successfully and outputs:

psql (14.9 (Ubuntu 14.9-0ubuntu0.22.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

iam using ubuntu : Linux d 5.19.0-50-generic #50-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 10 18:24:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux and psql --version is : psql (PostgreSQL) 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1)

content of postgresql.conf is as follows:

data_directory = '/var/lib/postgresql/14/main'      
hba_file = '/etc/postgresql/14/main/pg_hba.conf'    
ident_file = '/etc/postgresql/14/main/pg_ident.conf'    
external_pid_file = '/var/run/postgresql/14-main.pid'           
listen_addresses = '*'      
port = 5433             
max_connections = 100           
unix_socket_directories = '/var/run/postgresql' 
ssl = on
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
shared_buffers = 128MB          
dynamic_shared_memory_type = posix  
max_wal_size = 1GB
min_wal_size = 80MB
log_line_prefix = '%m [%p] %q%u@%d '        
cluster_name = '14/main'            
stats_temp_directory = '/var/run/postgresql/14-main.pg_stat_tmp'
datestyle = 'iso, mdy'
lc_messages = 'en_US.UTF-8'         
default_text_search_config = 'pg_catalog.english'
include_dir = 'conf.d'          

i also tried this solution but it didn't work, beside,this is not really a safe way to achieve it!

  • try localhost instead of the ip – nbk Aug 22 '23 at 13:19
  • Similar question at serverfault: [cant-connect-to-postgresql-on-local-machine-using-ip-pgadmin](https://serverfault.com/questions/443153/cant-connect-to-postgresql-on-local-machine-using-ip-pgadmin) I wouldn't say its "not safe" to allow connections from ip addresses. You don't have to allow all connections - just the ones that need access. psql isn't using http to connect, that's why its working. PgAdmin does use http, so postgres needs to be configured to allow http connections. – topsail Aug 22 '23 at 13:57
  • @nbk i did. unfortunately nothing changed !;( – littleNicky Aug 24 '23 at 08:52
  • @topsail i did the thing you mentioned, still no luck, i really have no idea what else to try! – littleNicky Aug 24 '23 at 09:09
  • Its a little odd I guess. When you say you are running pgadmin locally - is everything local? Like you are working on your own projects (school/personal/hobby) where everything is local and there are no outside connections? Or is this a production setup or something at work? What is the contents of your `postgresql.conf` file? – topsail Aug 24 '23 at 14:01
  • do you really have a user `root` is that a user you created? – topsail Aug 31 '23 at 12:32
  • @topsail yes, that's a user created with createdb and superuser access – littleNicky Aug 31 '23 at 13:02
  • Lots more things to try here: https://stackoverflow.com/questions/38466190/cant-connect-to-postgresql-on-port-5432 – topsail Aug 31 '23 at 15:42

0 Answers0