Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 575
MikeLiu Avatar asked Mar 18 '26 00:03

MikeLiu


1 Answers

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'

like image 168
Scott Moniz Avatar answered Mar 20 '26 20:03

Scott Moniz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!