Ninja Space Content Tech Blog

Postgres issue

Posted by Ninja Space Content on Tuesday, May 18, 2021 Under: postgres
Today, I ran into a postgres connect issue when I was going back to a database under development on my localhost because I needed to add another feature. This was the error that I received in my terminal when I tried to 'npm run start':

psql: error: could not connect to server: could not connect to server:


I never ran into this problem before so I am thinking maybe something needed updating because even my Postico was not opening my databases. I googled this error and found that someone with a Mac had this problem and fixed it by typing the following command in the terminal:

brew install postgres


Then, my terminal prompted me with the following:
To have launchd start postgresql now and restart at login:
brew services start postgresql
so, I copied and pasted brew services start postgresql

And then typed in: psql in my terminal and it was giving me this error: psql: error: could not connect to server: FATAL:  database "******injaspace" does not exist. 

After that I figured I had to enter createdb in the terminal and it looks like my old databases were wipe out. So in order to get my existing database to work again like it did a couple of weeks ago, I had to create the database again so I entered:

CREATE DATABASE roses;
because roses was what I called my database. So I went back to my project in Visual Studio Code, started the server and voila, the error went away. I seeded my data and it is back now. This took me a good 45 minutes to debug. Hope it'll help you.

Note: I put ****** in place of part of my username for privacy above.

In : postgres 


Tags: postgres  psql issue  psql: error: could not connect to server: 

About Ninja Space Content


Ninja Space Content I have been building simple websites on my own since 2008 and currently run several websites at the moment, including this one. I used to be an account manager for an affiliate/e-commerce company, helping affiliates grow their sales so I have some knowledge on the business side and client side of affiliate marketing. Most recently, I decided to complete a JavaScript coding bootcamp and graduated in Dec 2020.
Note: links to resources and promoting special deals may allow me to earn a small commission from each sale.