Unable to connect successfully to a local Postgres db using Vscode mssconnect extension - postgresql

Whenever I try to add a connection profile using msconnect, I run into the issue shown below.
I've followed these instructions to no avail. It's worth noting that I have no issue querying the database with other IDEs like Pycharm or Datagrip.
For more information,
OS is macOS Monterey
it's a locally running Postgres container on port 5434 so I specify localhost,5434 as the server name when creating the connection
username & password were double-checked
mssql: Error 203: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - 17735680)

Related

pgbouncer throws Pooler Error: Auth Failed when using datagrip but NOT when using pgadmin

I have a postgres database (version 9.2) running on Centos 6.9.
I am running pgbouncer version 1.6.1
When I try connect to postgres using datagrip from my Mac, I get:
08P01: Error: Auth Failed
And I get on the server:
/var/log/pgbouncer.log
2021-05-21 18:29:02.644 7489 WARNING C-0x15cf078: postgres/jode#127.0.0.1:56254 Pooler Error: Auth failed
When I login to postgres using Pgadmin 4 from the same Mac and same settings, I get right in and there are no errors or warnings in pgbouncer.
What could the problem?
PgAdmin is not working via JDBC. So you need to configure pgBouncer to accept TCP/IP connections (see similar dba exchange question)

How to set up localhost server and database for PostgreSQL?

I am new to PostgreSQL, and I want to use it on my personal laptop for personal projects. I use SQL Server and SQL Server Management Studio at work, coding-wise I'm ok but I need some help with setting up the localhost on my laptop.
So I downloaded PostgreSQL and installed it along with pgAdmin that came with the package.
During installation, it asked me to create a PostgreSQL superuser password, which I did.
Then I tried creating a new server using pgAdmin as follows:
General Tab:
Name: localhost
Server Group: Servers
Connect Now?: check
Connection Tab:
Host name/address: localhost Port: 5432
Maintenance database: postgres
Username: postgres
Password: [blank]
But when I click save I'm getting an error message:
Unable to connect to server: could not connect to server: Connection
refused (0x0000274D/10061) Is the server running on host
"localhost"(::1) and accepting TCP/IP connections on port 5432? could
not connect to server: Connection refused (0x0000274D/10061) Is the
server running on host "localhost"(127.0.0.1) and accepting TCP/IP
connections on port 5432?
Also tried replacing the password field with the Superuser password, getting the same error message.
Would greatly appreciate it if anyone offers any insights into this problem, I might just be a noob when it comes to server setups...
Thanks,
Mike
Update:
I believe there's a service I need to start as suggested by #Scott Moniz. I went into services.msc, tried to start the service postgresql-x64-10 - PostgreSQL Servier 10, and I got this error message:
"The postgresql-x64-10 - PostgreSQL Server 10 service on Local
Computer started and then stopped. Some services stop automatically if
they are not in use by other services or programs".
I then tried editing the property of the service, by changing the Log on as option to Local System Account and tried starting the service again, still got the same error message.
I'm using Windows 10 Home edition, it this helps to resolve the issues in anyway
Thanks,
Mike
Are you sure the database service is running and listening?
CLick Start>Run> type services.msc
Look for a postgresql service - if it does not say started right click it and click Start.
Alternatively you can restart your computer and the service should start if it is set to 'Automatic'

HEROKU POSTGRES error: Connection refused Is the server running on host "..compute-1.amazonaws.com..." and accepting TCP/IP connections on port 5432?

I have been trying for weeks to figure out what's the issue, but I cannot seem to fix this.
I am developing a web app, and I have deployed to production using Heroku. I'm using Heroku Postgres for my database, and I'd like to psql into that hosted database from my local machine to make changes to it. I have tried from both Mac OS X and Linux Mint.
However, no matter what I try, I keep getting the following error:
---> Connecting to HEROKU_POSTGRESQL_ORANGE_URL (DATABASE_URL)
psql: could not connect to server: Connection refused
Is the server running on host "ec2-***-**-***-**.compute-1.amazonaws.com" (***.**.***.**) and accepting
TCP/IP connections on port 5432?
I'm starting to think that I may have to SSH into the Amazon EC2 instance and change the Postgres configuration? Would that even be possible?
You can't connect directly to the EC2 instance where the Heroku Postgres instance is running; it is managed by Heroku and normal users aren't allowed to connect to it.
If your application is running fine in Heroku, and you're running heroku pg:psql to attempt to connect to the DB, then most likely there is some issue with your local network that is preventing you from connecting to the Postgres database, like a firewall blocking outbound connections. Heroku Postgres databases are open to the public without any restriction on IP ranges.
It could be a problem with the proxy or firewall of the internet connection you are using.
Try to connect your PC to your mobile phone tethering and then launch the command again, just to verify if the problem lies there.
I was getting this kind of error when my pg_hba.conf or AWS security groups have not been configured properly. There are plenty of docs about how to resolve this. For example, you can check this list link
You can directly connect to EC2 Heroku Postgress instance by adding this attributes to the end of your DB connection url:
jdbc:postgresql://<host>/<dbname>?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

bugzilla can't connect to postgres server

I just installed bugzilla-4.4.1 on version 6.4 of Scientific Linux, and I'm having problems connecting to the database (Pg version 8.4).
When I try to fetch the main page (index.cgi), I get the following message:
Software error:
Can't connect to the database.
Error: could not connect to server: Permission denied
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Is your database installed and up and running?
Do you have the correct username and password selected in localconfig?
For help, please send mail to the webmaster (root#localhost), giving this error message and the time and date of the error.
Postgres's pg_hba.conf.conf is configured for md5 auth on localhost:
host all all 127.0.0.1/32 md5
and I can connect to the bugs user in the database using psql:
psql -h 127.0.0.1 -U bugs
Running checksetup.pl seems to confirm that the database is set up and configured properly:
... snip ...
Reading ./localconfig...
Checking for DBD-Pg (v2.7.0) ok: found v2.15.1
Checking for PostgreSQL (v8.03.0000) ok: found v08.04.1800
Removing existing compiled templates...
Precompiling templates...done.
Fixing file permissions...
Now that you have installed Bugzilla, you should visit the 'Parameters'
page (linked in the footer of the Administrator account) to ensure it
is set up as you wish - this includes setting the 'urlbase' option to
the correct URL.
checksetup.pl complete.
[root#PAHRALBLNX001 bugzilla]#
and the testserver.pl script indicates that the server is set up properly:
[root#PAHRALBLNX001 bugzilla]# ./testserver.pl http://127.0.0.1/
TEST-OK Webserver is running under group id in $webservergroup.
TEST-OK Got padlock picture.
TEST-OK Webserver is executing CGIs via mod_cgi.
TEST-OK Webserver is preventing fetch of http://127.0.0.1/localconfig.
I've also verified that the bugs username and password in localconfig matches the setup in Postgres.
The one thing that seems odd however, is that when I look at localhost with Wireshark, I don't see any attempts to connect to the PostgreSQL server while accessing the bugzilla main page. However, if I connect to the PostgreSQL server using psql, I do see the connection in Wireshark.
Edit
I also discovered that bugzilla wouldn't send email. This turned out to be a selinux problem as pointed out by Daniel Vérité. I changed httpd_can_sendmail and httpd_can_network_connect to true, and now it works.
Based on the error message:
Error: could not connect to server: Permission denied
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Permission denied when trying to connect to an IP address means it's denied by the local security policy.
The web server must be enabled to connect to databases with this command:
setsebool -P httpd_can_network_connect_db 1
and if it's not sufficient:
setsebool -P httpd_can_network_connect 1
See http://wiki.centos.org/TipsAndTricks/SelinuxBooleans for more

general sql error

I have created an application in delphi and backend is postgres when i run the application i get the following error
general sql error.could not connect to the server;no
connection could be made because the target machine actively refused
it.[127.0.0.1:1:5433 alias resumep
I uninstalled it and installed it again but it didnt work.Even i changed the port number while installing .
I changed the password and installed again but its giving same error
what is the solution to this problem?
The database cluster of a standard PostgreSQL installation is listening on port 5432. (You can, of course, set up additional db clusters on different ports or configure your database cluster to listen on any other port.)
Any particular reason you try 5433? This is probably the cause of your problem.
If no server is listening on port 5433, the connection is simply not possible.