#How to remotely access postgres sql server from different client on the same/outside network

63 messages · Page 1 of 1 (latest)

wooden bane
#

Hello Guys I installed postgresql database on my ubuntu Server running on top of Porxmox Virtual Server. I installed postgresql for testing django website. But when I try to connect from the client it throw error saying password authentication failed evern after everything is correct.

#

Database administrative login by Unix domain socket

local   all             postgres                                peer

TYPE  DATABASE        USER            ADDRESS                 METHOD

"local" is for Unix domain socket connections only

local   all             all                                     peer

IPv4 local connections:

#host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             0.0.0/0                 md5

IPv6 local connections:

#host    all             all             ::1/128                 scram-sha-256
host    all             all             ::0/0                   md5

Allow replication connections from localhost, by a user with the

replication privilege.

local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replica4tion     all             ::1/128                 scram-sha-256

wooden bane
#

and on postgresql.conf file I edit the listerners to '*' but still I get the error.

honest aurora
#

Can you connect to it from the server itself?

wooden bane
#

yes sir but I see some error

wooden bane
# honest aurora Can you connect to it from the server itself?

sudo su postgres
[sudo] password for nehat: 
postgres@nehatlab:/home/nehat$ psql
could not change directory to "/home/nehat": Permission denied
psql (15.2 (Ubuntu 15.2-1.pgdg22.04+1))
Type "help" for help.
I get this error when I access internally.
Could not chnage directory to .......... Permission Denied

but I am able to access the server and do the things like creating and deletng the database

honest aurora
wooden bane
#

os sorry sir one second

#
sudo su postgres
[sudo] password for nehat: 
postgres@nehatlab:/home/nehat$ psql
could not change directory to "/home/nehat": Permission denied
psql (15.2 (Ubuntu 15.2-1.pgdg22.04+1))
Type "help" for help.
I get this error when I access internally.
Could not chnage directory to .......... Permission Denied

@honest aurora

honest aurora
#

Haha I meant only for code. Not your response. No worries

wooden bane
honest aurora
#

What user does your client specify for connecting to the database?

#

It's fine. Don't worry

wooden bane
honest aurora
wooden bane
#


# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
#host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             0.0.0/0                 md5
# IPv6 local connections:
#host    all             all             ::1/128                 scram-sha-256
host    all             all             ::0/0                   md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replica4tion     all             ::1/128                 scram-sha-256

sir is the setting code
@honest aurora

honest aurora
#

If we get to manipulating that setting, I can't help you

wooden bane
honest aurora
#

It would be beyond my knowledge

wooden bane
wooden bane
honest aurora
#

The W parameter causes you to enter the password in a follow up prompt

wooden bane
#

I tried running psql it throw error psql command not found

honest aurora
wooden bane
#

as on my mac potgress is not isntalled

wooden bane
#

the gui app

honest aurora
wooden bane
#

I would have share the screenshot but here sharing media is not allowed

wooden bane
honest aurora
#

From the server, using your user (don't change to postgres), connect to the database with psql specifying the postgres user.

honest aurora
wooden bane
#

yes sir

honest aurora
#

I got like 4 ad pop-ups and never got to your image

honest aurora
wooden bane
#

sir here is the link of the image

honest aurora
#

If that works, then this is what I would try next. But like I said, this is outside my knowledge. https://stackoverflow.com/a/22083740
Basically it's what you've done, but also restarting the postgres server / reloading the config

wooden bane
honest aurora
#

You may want to try the postgres irc

wooden bane
#

I change the passowrd of the postgress user which is default

#

than with the command you say above wont work

#

ALTER USER user_name WITH PASSWORD 'new_password';

ALTER USER postgress WITH PASSWORD '123456789';

#

now when I try to access the database locally with the command

#

psql -u postgres -W postgres
than it ask me password and when I type the password which I just change, it doens work and throw error

#

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"

honest aurora
#

I don't know what to tell you. The computer doesn't lie. Something is misconfigured

wooden bane
#

should I uninstalled and then installed again

honest aurora
#

That's what I'd do

#

Besides seeking advice from the wizards of postgres irc

wooden bane
#

okay sirI will try reinstalling the server again and than check

#

if again no success than will go for irc

#

thanks a lot for your hlp sir

honest aurora
#

Best of luck!

wooden bane
# honest aurora Best of luck!

sir its done I was not giving ';' after the query thats why postgres password was not setting up and on client I was using the password

#

silly me

honest aurora
#

Ah, good work on figuring that out! Those issues can be pesky