Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psql: error: could not connect to server: No such file or directory #3

Open
moldach opened this issue Aug 23, 2021 · 7 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@moldach
Copy link

moldach commented Aug 23, 2021

When running bash 00-postgres-init.sh I'm met wit the follwing error (from line 26):

psql: error: 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"?
@moldach
Copy link
Author

moldach commented Aug 23, 2021

Need to install postgressql.
On Mac is used brew install postgresql then start the server via brew services start postgresql.

@moldach moldach closed this as completed Aug 23, 2021
@moldach moldach reopened this Aug 23, 2021
@moldach
Copy link
Author

moldach commented Aug 23, 2021

Despite having installed postgresql and trying to restart I'm still getting errors?

oldachm-TJLVDG:postgresql oldachm$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
oldachm-TJLVDG:postgresql oldachm$ bash 00-postgres-init.sh 
Directory /Users/oldachm/docker/volumes/postgres exists.
37a78e8c93a4904da9812ea5afa5515c7c5230ee26675c2bd36bbcfb5c01f5d9
psql: error: 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"?
post_setup

@moldach
Copy link
Author

moldach commented Aug 23, 2021

Above, It seems to be looking for /var/run/postgresql/.s.PGSQL.5432; however, when I run the following (below) from the command line I see that it's actually listening on Unix socket /tmp/.s.PGSQL.5432:

$ postgres -D /usr/local/var/postgres
2021-08-23 14:08:58.896 MDT [97709] LOG:  starting PostgreSQL 13.4 on x86_64-apple-darwin19.6.0, compiled by Apple clang version 12.0.0 (clang-1200.0.32.29), 64-bit
2021-08-23 14:08:58.898 MDT [97709] LOG:  listening on IPv6 address "::1", port 5432
2021-08-23 14:08:58.898 MDT [97709] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-08-23 14:08:58.900 MDT [97709] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-08-23 14:08:58.908 MDT [97710] LOG:  database system was shut down at 2021-08-23 13:19:18 MDT
2021-08-23 14:08:58.914 MDT [97709] LOG:  database system is ready to accept connections

Not sure if that information is helpful (or how to fix the problem)?

@rsangole
Copy link
Owner

rsangole commented Oct 5, 2021

Hey @moldach, sorry lost track of this.

Did you find a fix, or is this still an open issue?

@moldach
Copy link
Author

moldach commented Oct 10, 2021

Still an open issue

@lzachmann
Copy link

Same error here, no luck running 00-postgres-init.sh. Any possible leads?

@rsangole
Copy link
Owner

@moldach and @lzachmann - could you try the fix I've put here.

I've faced a similar issue and it stems from the Postgres server not being ready to accept connections just yet. This piece of code waits for the server to start accepting connections before proceeding.

@rsangole rsangole self-assigned this Jan 18, 2022
@rsangole rsangole added the bug Something isn't working label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants