PostgreSQL windows/MacOS installation and error fix :couldn't connect to server


PostgreSQL  error fix :couldn't connect to server and installation





According to this PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance. 

So first we look forward to installation procedure and then we will try to fix the error :couldn't connect to server later ..

1. Windows installation of PostgreSQL   Click to Download  install the Postgres with the package
    once you download we will move to install the package see the following steps to install it.



2.


3. So once you install this you have  pgAdmin in your package open it and then move forward in creating the database in the pgAdmin you can do this in two ways either in pgAdmin or the shell of postgreSQL, so we will move to create server now.



4. For this Server > Create > Server


5. You can also do by this method to create server in shell


6. Coming towards DB creating database again can be done in the cmd prompt or using the pgAdmin
  so here you need to give cmd
createdb -h localhost -p 5432 -U postgres projectname

createdb -h localhost -p 5432 -U postgres projectname password


So, here we are done with creating Server and DB so now lets move on to fixing our error.

 Error fix :couldn't connect to server

When connecting to a PostgreSQL server, you may get an error message this is most common error look forward to fix this issues these might be any possible solution for the error

First solution:


1. First check the status of the postgres if it shows online then you can stop and restart it.
sudo service postgresql status

2. sudo service postgresql stop

3. sudo service postgresql start

4. sudo service postgresql restart


Second solution :
1.open PostgreSQL.conf

cd /etc/postgresql/9.x/main/

2. And the add this to the file

sudo vi postgresql.conf

3. Open pg_hba.conf

listen_addresses = '*'

4. Add this
sudo vi pg_hba.conf

5. Now it will allow access to all DB with password
host all all 0.0.0.0/0 md5

6. Restart your server
sudo /etc/init.d/postgresql restart




My Instagram

Made with by Pi-girl | Copyright © 2020 Pi-girl