#How to remotely access postgres sql server from different client on the same/outside network
63 messages · Page 1 of 1 (latest)
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
I edited the pg_hba.conf file and allow all host to access the server
and on postgresql.conf file I edit the listerners to '*' but still I get the error.
Can you connect to it from the server itself?
yes sir but I see some error
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
Use formatting please. Check #readme-1st for how
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
Haha I meant only for code. Not your response. No worries
oh sorry sir one second
What user does your client specify for connecting to the database?
It's fine. Don't worry
I dont know, I am just new with this. I have not created any user yet. just accessing the postgres which is default user, I guess
Hmm. Let's step back. What exactly are you doing when you say you try to connect from the client and what are you seeing happen?
# 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
If we get to manipulating that setting, I can't help you
why sir. Is there anything wrong?
It would be beyond my knowledge
I am runnig postgress on a ubutu server vm and on my mac on the same network I am suing pgadmin client to access it by giving the host address of the ubuntu server.
oh
For that connection, what user are you specifying?
Did you try running psql from your client, specifying the user and database? I think it's psql -U username -W dbname
The W parameter causes you to enter the password in a follow up prompt
postgres which is default.
I tried running psql it throw error psql command not found
Were you having to enter a password?
as on my mac potgress is not isntalled
I think you misunderstood. Did you have to type a password in?
I would have share the screenshot but here sharing media is not allowed
yes sir
sir please check this image
Download Screenshot 2023-05-06 at 1.18.41 PM.png for free from ufile.io instantly, no signup required and no popup ads
From the server, using your user (don't change to postgres), connect to the database with psql specifying the postgres user.
Use imgur
yes sir
I got like 4 ad pop-ups and never got to your image
Don't forget about this either. This is still the next step
okay sir
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
I am doing the sam thing but dont know where I am wrong.
You may want to try the postgres irc
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"
I don't know what to tell you. The computer doesn't lie. Something is misconfigured
yes, sir, I agree with you. Something is wrong.
should I uninstalled and then installed again
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
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
Ah, good work on figuring that out! Those issues can be pesky