I’m in a difficult situation where I tried so many times but my Laravel application not getting connected to any of the PostgreSQL databases
First I tried to create an AWS PostgreSQL database and tried to connect I got
could not connect to server: Connection refused Is the server running on host “XX.XXX.XXX.XXX” and accepting TCP/IP connections on port 5432 error.
Then I thought something wrong with the AWS firewall so after wasting some time I moved to hostinger vps.
Where I have hosted my Laravel application. I installed Postgres and pgadmin web-versions there. I could successfully connect to Postgres via pgadmin but I couldn’t connect to the database via the Laravel application.
Then I tried to use same posgtgres credentials on my local environment clone of the Laravel application and it worked without issues.
Then I created a separate Postgres database in google cloud and again tried to connect it via Laravel application hosted in Hostinger but that also got failed.
As I earlier mentioned I have the pgadmin installed in Hostinger VPS, so I tried to connect to the google cloud Postgres database via pgadmin. It got connected without any issues.
Anyway I still couldn’t connect my Laravel application to get connected with any of these Posgres databases.
I”m getting the same error always
QLSTATE[08006] [7] could not connect to server: Connection refused Is
The server running on host “XX.XXX.XXX.XXX” and accepting TCP/IP
connections on port 5432?
I have checked Laravel env for many many times, and as I do successfully connect to the database in my local environment I can guarantee that I did the config and credential setting in the .env file correctly.
As I can connect using pgadmin the credentials are also 100% correct.
In Google I have add the IP address of the VPS and the C-panel shared IP address as connection networks.
Exact clone of the local environment source code exists in the VPS C-panel.
I did PHP artisan optimize after updating the .env
I’m out of options now. 🙁
Please enlighten me on how to over come this issue.