1

macos ventura 13.5.1 postgresql (15.4 (Homebrew))

Remote connections for the server are closed "unexpectedly". I have done all the steps that are needed for postgres to be happy with remote connections on other unix systems, eg: ubuntu. I know that it's seeing the connection attempt since there is a line added in the log at the same time. So it doesn't seem like this is a firewall issue.

On that mac. all local connections are happy and the server is working normally. I don't recall ever seeing the TCP_NODELAY message on any other installation I have done and googling this issue didn't seem to find meaningful results

postgres was installed via:

brew install postgresql@15

connecting to the database like this shows an error:

psql a_database --host an_ip_address --username a_username
psql: error: connection to server at "an_ip_address", port 5432 failed: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
(

Yes, I know I might want to have a more specific ipaddress eg: 10.0.0.0 but I wanted to make sure I could connect.

In pg_hba.conf:

# remote connections with password verification
host    all             all             0.0.0.0/0               md5

In postgresql.conf:

listen_addresses = '*'

In the log for postgres at the time of connection is:

2023-08-25 13:55:02.966 PDT [743] LOG:  setsockopt(TCP_NODELAY) failed: Invalid argument

1 Answer 1

0

With a very similar setup and error message (only a newer macOS version), this change worked for me:

In postgresql.conf, change the '*' into a list of addresses:

listen_addresses = 'localhost,12.34.56.78'

where 12.34.56.78 is your actual IP address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.