How to resolve `SSL SYSCALL Error` with a PostgreSQL Database on Azure? - psql

After restarting my PostgreSQL on Azure Database Instance, I can no longer connect via any client and I receive: psql: SSL SYSCALL error: EOF detected with psql.
I used the Restart button on the Azure Database for PostgreSQL server overview page.

Most likely server was in the process of rebooting. Check in the server logs server start time. Probably it will be after you issues your connection request. If you have heavy workload running then recovery is expected to take longer.

Related

Unable to connect Azure Database from Kubernetes cluster using Kubeadm

I have a MVC application which is using Azure SQL database for data storage. I have created a docker image for the same.
Later, I have setup Kubernetes cluster on Ubuntu 18.4 using Kubeadm. The Linux VM is is created on azure cloud.
Initially, i have deployed my app on the single node cluster and the application was working as expected without any SQL connection issue. Then I have created two VM on the cloud and used it as Node 1 (master) and Node 2. Now i am facing an SQL connection issue after deploying my app on Node 2 machine.
Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Resource temporarily unavailable
I tried and verified below options-
Added IPs to Azure SQL database firewall settings
From Linux Machine, tried to connect SQL database using sqlcmd
POD network is install correctly (calico)
Tried adding outbound rule for SQL port 1433 on VM
I have created a SQL database on VM and tried to connect this database from MVC app and it is also working.
Can someone please help me to diagnose and fix this issue? Please let me know if you want more details on this.

cannot connect to Heroku Postgres - error "server closed the connection unexpectedly"

I am trying to use the Heroku CLI to connect a Postgres database in the cloud.
heroku pg:info shows the database information, but heroku pg:psql fails with the following error:
$ heroku pg:psql
--> Connecting to postgresql-<database-id>
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
What's wrong?
Port 5432 must be unblocked for psql to work and I was unable to do that. Switching to a different network (e.g. Internet provider at home or mobile Internet) may help.
Might not be the issue for everyone, but if you have a computer set up to connect with mTLS by having a ~/.postgresql/postgresql.crt and ~/.postgresql/postgresql.key, psql will automatically send the key up to all databases you connect to, and you will break heroku pg:psql connections to other databases
So just
mv ~/.postgresql{,.bak}
and try again. If that's your issue, you'll want to put your mTLS certs in a different directory and manually pass them as arguments or via config vars
The location of the certificate and key files can be overridden by the
connection parameters sslcert and sslkey or the environment variables
PGSSLCERT and PGSSLKEY

Receiving "ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out" in rake task

In my rake task, I'm connecting to postgresql via a pgbouncer setup. For some queries I receive this error:
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() could not receive data from server: Connection timed out
In my pgbouncer log, I see this entry:
closing because: client unexpected eof (age=3110)
I have disabled prepared statements in my config/database.yml file and enabled transaction pool_mode in my pgbouncer config file.
When I directly connect to postgres, I don't get this error.
Also in my rake task, I am creating multiple threads. I tried running ActiveRecord::Base.connection.reconnect! inside my threads as suggested here. That didn't help either.
I am using rails version 4.2.5 which has this fix. I'm still getting this error "could not receive data from server: Connection timed out".
This was caused due to network issues in clients. Not able to reproduce since we migrated both server and client to Google Cloud Platform. Earlier our server was in DigitalOcean while our clients were in GCP.

Engine Yard error related to postgress and socket '/var/run/postgresql/.s.PGSQL.5432'

I have a rails application hosted on Engine Yard Cloud. After deploy I am getting an error:
Process postgresql: POSTGRES_CONNECTION CRITICAL: DB 'postgres' could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket '/var/run/postgresql/.s.PGSQL.5432'
After this error the instance with the application become unreachable and reloading the instance is required. After reloading the instance I can deploy once, but with the next deploy I am getting the same error. I would appreciate any ideas on how to solve this.
The most likely cause of this condition is that the Postgres server has stopped responding. This most commonly occurs due to a low memory condition on Solo instances but can have other causes as well. The best way to explore this further is to file a ticket with the Engine Yard Support team and we can investigate this further for you.
Thank you,
Tyler

Postgresql, problems after updating gem

I just updated my gems. And now I have problems connecting to my postgresql database. I get the error:
PGError
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I tried uninstalling the gem and reinstalling, I also tried to change the paths file and put '/usr/local/bin/' on top. I tried some of the things from post:
Repairing Postgresql after upgrading to OSX 10.7 Lion
This app worked fine before updating my gems, other apps still connect just fine, to the same server. I have the same settings in my database.yml file.. what could be wrong?
The error comes from the PostgreSQL server and I have seen it many times. It tells you that you are trying to connect via Unix domain socket (and not via TCP/IP!) to a server that is running locally and listening at port 5432. But no server can be found that would accept connections like that.
You did not mention where the PostgreSQL server resides - I assume you actually mean to connect to a database server on your local machine.
Check your setup, especially your pg_hba.conf file. You need a line like:
local mydb myuser md5
or
local all all peer
or some other connection method that includes your user and database.
These would not help in your case:
host ...
or
hostssl ...
They concern TCP/IP connections, not local connections via UNIX domain socket. When you connect to localhost you actually use TCP/IP via local loop and these settings apply.
Remember to reload after you edit pg_hba.conf. I quote the manual at the linked site:
If you edit the file on an active system, you will need to signal the
postmaster (using pg_ctl reload or kill -HUP) to make it re-read the
file.

Resources