0

Setting up Postgres on Windows for frontend web dev

This is not my area of expertise (frontend guy), but I need postgres simply running on my side to connect with the test DB for the project I'm working on:

I have to run this before I start my project: dropdb [db_name] && createdb [db_name] && npm run migration:run:dev

When I do so, I get the typical:

dropdb: could not connect to database template1: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

This tells me that postgres isn't running on port 5432, which I verified in Resource Monitor and inside pgAdmin... in pgAdmin, all the PIDs are NOT 5432 and when I try to change the port to 5432 (although, already set to that), I get:

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? 

I have postgres installed via the packaged installer, and I've tried various solutions, such as: https://tableplus.io/blog/2018/10/how-to-start-stop-restart-postgresql-server.html https://stackoverflow.com/questions/38466190/cant-connect-to-postgresql-on-port-5432 (I don't need remote connections)

Note(s)

I use homebrew to do this on my mac in like 2 commands... but services doesn't work with linuxbrew. I don't think my network is an issue if my mac has no problem with it on the same network.

I'm thinking something could be running on port 5432, but nothing appears to be in Resource Monitor.

Output from netstat -tlna | grep 5432

Nothing...

Edits

  1. It seems the PID in Network Resource and pgAdmin don't refer to the port it's running on???
  • So, does Postgres run? And "PIDs" have not relation to a port whatsoever. But if you can look at the PIDs from within pgAdmin you can clearly connect - so how did you do that? – a_horse_with_no_name Mar 13 at 6:49
  • The message "Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432?" indicates that you are not running on Windows, but on some kind of Linux. Because on Windows that error message does not include the reference to the domain socket. – a_horse_with_no_name Mar 13 at 6:57
  • Give us the output of netstat -tlna | grep 5432. Not sure of the exact syntax for Mac! – Vérace Mar 13 at 10:33
  • Connection refused (0x0000274D/10061) is an error produced by Windows, 10061 being WSAECONNREFUSED. But as mentioned in previous comments, the dropdb message does not come from Windows. You mention you don't need remote connections but that seems to be contradicted by these error messages. – Daniel Vérité Mar 13 at 15:39
  • @a_horse_with_no_name I went to pgAdmin, found my server on the left, connected via entering my password. Also, I'm using bash in hyper.js (terminal). That's the error it gives me and I'm definitely running windows... – Chris Johnson Mar 13 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.