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

Cannot connect to database via Unix socket #696

Closed
lilyminium opened this issue Oct 29, 2021 · 1 comment
Closed

Cannot connect to database via Unix socket #696

lilyminium opened this issue Oct 29, 2021 · 1 comment

Comments

@lilyminium
Copy link

lilyminium commented Oct 29, 2021

Describe the bug

This is a repeated problem on my Mac OS Catalina (10.15.7). I haven't tried other architectures. On the Linux cluster the package works very well as installed, but I believe that's a TCP connection. (I don't know anything about Postgres, such as whether the default protocol is expected to be TCP.)

To Reproduce

This is the error I get using qcfractal 0.15.6 and the default environment in the quickstart notebook in #695, but with +chardet, +importlib_resources, and with qcelemental 0.22.0 instead of 0.23.0.

>>> server = FractalSnowflakeHandler()

(from printing stderr)

createdb: error: 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 "/tmp/.s.PGSQL.49462"?

The command is ['/Users/lily/anaconda3/envs/snowflake/bin/createdb', '-p', '49462'].

Expected behavior

Additional context

If I hack PostgresHarnes._run to pass in localhost, it switches to Unix sockets.

def _run(self, commands):
proc = subprocess.run(commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout = proc.stdout.decode()
if not self.quiet:
self.logger(stdout)
ret = {"retcode": proc.returncode, "stdout": stdout, "stderr": proc.stderr.decode()}
return ret

	def _run(self, commands):
+        command_str = " ".join(list(map(str, commands)))
+        if (any(x in command_str for x in ["-p ", "--port="])
+                and not any(x in command_str for x in ["-h ", "--host="])):
+            commands.extend(["-h", "127.0.0.1"])

        proc = subprocess.run(commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout = proc.stdout.decode()
        if not self.quiet:
            self.logger(stdout)

        ret = {"retcode": proc.returncode, "stdout": stdout, "stderr": proc.stderr.decode()}
        return ret
@bennybp
Copy link
Contributor

bennybp commented Sep 14, 2023

I think this is all working in v0.50, but it not, then let me know!

@bennybp bennybp closed this as completed Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants