PostgreSQL Question ! Port problem :( (0x0000274D/10061) - postgresql

My cmd is looking for port 5432. Initially, it was set as 5433 in installation so I had to change it from postgresql.conf. But then I could not use pgAdmin because it is looking for port 5433 how do I make one of them look for the same port?

It was a dumb question... But in case someone else has the same situation, the answer is to right-click on your server in pgAdmin, click properties and then change the desired port!

Related

Cannot start Postgres on port 5432

I just installed postgres.app, but when I try to start the server I get the following error:
After checking some answers in a similar thread I verified that my PATH is defined correctly and that no other process is running on port 5432:
So what's going on with port 5432?
Simple solution. Uninstalled and reinstalled and now everything works on port 5432. Very strange error, I am curious if anyone has any ideas about how this happened.

postgres doesnt restart after making the necessary .conf file changes

apologies first. On a steep learning curve more like a wall and will be verbose and lacking in jargon but too old to change that now. I'm trying to access a Postgresql-13 (with postgis-3 extensions) database from a machine other than the one where it is hosted. Before doing anything at all other than install, create and consume a spatial data file, this is the partial screen dump from
sudo netstat -ltpn
Proto
Recv-Q
Send-Q
Local Address
Foreign Address
State
PID/Program name
tcp
0
0
127.0.0.1:5432
0.0.0.0:*
LISTEN
993/postgres
... and the database is accessible from pgadmin4 on the Ubuntu 20.04 machine which is hosting it. I can also connect to the database in QGIS on the same Ubuntu machine through 127.0.0.1 and port 5432. Nothing special about that other than knowing it works. What I want to do is connect to that database from any machine running QGIS (or another GIS platform which can consume postgis).
Port forwarding rules on the router are set for 80, 8080 and 5900 to point to 10.0.0.55 which is the IP for the Ubuntu 20.04 which is hosting. I have a dynamic DNS pointing the routers IP to give it the name http://blah.blah.net (not actually that, but close).
pgadmin4 is installed and configured to run in server and I can access the database through pgadmin4 from the host or any other computer using http://blah.blah.net/pgadmin4. Not sure I got this config quite right but it works. Geoserver is also running smoothly on Tomcat9 accessible from anywhere through http://blah.blah.net:8080/Geoserver/web/. And a fancy front end in the making on http://blah.blah.net.
Have then done the following mods to the two .conf files in etc/postgresql/13/main which are well noted and documented already ...
host all all 0.0.0.0/0 md5
in the pg_hba.conf
and also ...
listen_addresses='*' (and removed the leading #)
port = 5432 (was already)
in the postgresql.conf
Then restarted postgres with ...
sudo service postgresql restart
... and then port 5432 disappears completely and the database is not accessible from anywhere. Not even the host computer. Checked that postgresql was running with ...
sudo systemctl status postgresql
... which it appears to be. But am getting nothing from QGIS or pgadmin4. Not even from the host machine.
Got a lot of questions but the most obvious is am I missing something? Not sure if I need a rule at the router for port 5432 - did try that in a similar fashion to the rules above but it didn't change anything. Appreciate any help. Cheers ... R
The local address in the netstat output:
127.0.0.1:5432
indicates that PostgreSQL is only listening on the loopback interface. Since you changed listen_addresses in postgresql.conf, I conclude that you forgot to restart PostgreSQL.
To confirm, run this query:
SELECT setting, pending_restart
FROM pg_settings
WHERE name = 'listen_addresses';
It should either show the wrong value (if you didn't reload or changed the wrong file altogether) or show pending_restart as TRUE (if you reloaded, but didn't restart).

postgres server running in local host, but postico, pgadmin can't access to it

I successfully installed postgres through homebrew, and i set it run automatically by doing
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
So, right now i can access to psql from my terminal (i use iterm2 + oh my zsh)
psql (9.6.1)
Type "help" for help.
ty2kim=#
The problem is, postgres management tools like postico, pgadmin cannot access to it
for postico, error message is
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5435?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5435?
which is weird because from my understanding, accessing to the database from terminal and management tools are basically the same if configured correctly
My pg_hba.conf and postgresql.conf are set as default (didn't make any changes there), but i tried doing
listen_addresses = 'localhost'
=>
listen_addresses = '*'
(restart server)
still didn't work
Please help!
Port 5435 is not standard for PostgreSQL. Are you sure PG is running on it? If you didn't change it in postgresql.conf it must be 5432. Please check it.
must check pg_hba.conf. If there doesn't have much restriction, you can put to end of this file by below line:
host all all all trust
After that, reload/restart instance.
Check if your PC is using firewall. If yes, please turn off it.

Should be able to run psql without host Postgres.app

Postgres.app documentation says this, verbatim: Once your path is correctly set up, you should be able to run psql without a host. (If not, check that the correct version is being loaded in the PATH by doing which psql) This is not so for me.
Here's where I'm at. WITHOUT the Postgres.app on (No elephant anywhere):
$ which psql
/Applications/Postgres.app/Contents/Versions/9.3/bin/psql
This is correct, and what Heroku says to look for. Heroku also tells me the command below should work, but it doesn't:
$ psql -h localhost
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
however I can get it to work when I double click postgres.app and turn it on.
$ psql
psql (9.3.3)
Type "help" for help.
johncurry=#
The docs specifically say that it should work WITHOUT the localhost. Am I set up correctly or do I need to change something? The code right above makes me feel like everything is working properly, but the "should work without a host" thing makes me unsure.
You're using the psql from postgres.app. It's configured to, by default, connect to the database server from postgres.app. That won't work if postgres.app is not running.
With our without -h, you must have postgres.app running.
If you want to run a background PostgreSQL server, postgres.app isn't what you want. Install from Homebrew or use the EnterpriseDB installer packages.

pgAdmin and PostgreSQL: can't connect to server

I just installed PostgreSQL on Snow Leopard and can't connect to the database server via pgAdmin 3.
I'm on my local machine, however I keep getting this error:
Could not connect to server: connection refused. Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5423?
I'm a bit of a noob when it comes to Postgres, so I'm not really sure what the problem is.
I can, however, log in through the command line, via psql -U postgres, and start and stop the server successfully.
Any help would be much appreciated.
The error message pointed out that you tried to connect to server on port 5423. However, postgres server listens on 5432 by default.
From your above comment (SHOW port; gives me "5432"), I think you need to change the port to 5432!
UPDATE: Tuan Dang spotted it. I'll leave this answer in place in case it helps someone else for whom the issue isn't quite the same.
Since you can connect via the command line, run:
SHOW port;
from psql. You'll probably see that the port is not 5432. You need to connect to the port PostgreSQL is actually running on from your application.
It's also possible that it just isn't listening on TCP/IP. Run:
SHOW listen_addresses;
to see what it's listening for.
The reason you can connect via the command line is likely to be because the command line psql you're using is connecting over a unix socket (since you didn't specify a host) and your app is connecting via tcp/ip.