Revisiting this topic since there is an exact title match and my application needs to make an outgoing connection.
Looking at the application log outputs (quoted below) I think I have two problems: 1. my machine is not resolving "localhost" properly; and, 2. which is relevant to this thread, I am sandboxed out of making network connections. I am hoping there is a resource I should be using to sort these problems. FWIW my system is the result of system upgrades dating back to 1988 so I'll not be surprised if something went wrong and it's only now I have noticed. 🤪
The recurring theme is socket error:
public static let SOCKET_ERR_GETADDRINFO_FAILED = -9989
Following the code I can confirm the error is at the request for a socket, and before any database login credentials have been presented. The database is perfectly functional from the point of view of psql and pgadmin4 (but they are likely using the unix:port to connect, ie., not the "localhost" route).
Any help will be appreciated. G
Context:
Building an application for personal productivity and learning exercise ("TheBooks3") to hook into the PostgreSQL server I am running on a local network
Using:
macOS Ventura 13.1 (Apple M1)
Xcode 14.2
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0
Packages:
PostgresClientKit (master), which uses Sockets 2.0.4
Application output below. The "DEBUG: ..." are from my application the other messages are produced through the Sockets class,
- With host = machine's own specific local network IP as per Network settings
DEBUG: We got to here
2023-01-14 08:10:55.833361+1100 TheBooks3[62799:3524343] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
2023-01-14 08:10:55.833473+1100 TheBooks3[62799:3524343] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
[2023-01-13T21:10:55.834Z Connection-1 severe] Unable to connect socket: Error code: -9989(0x-2705), Operation not permitted
DEBUG: Open connection failed
Database connection attempted
DEBUG: AccessDataBase.deinit
- With host = "localhost"
DEBUG: We got to here
2023-01-14 08:24:41.310094+1100 TheBooks3[63380:3534819] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:8 Err:-1 Errno:1 Operation not permitted
2023-01-14 08:24:41.310237+1100 TheBooks3[63380:3534819] [si_destination_compare] socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL) failed: Operation not permitted
2023-01-14 08:24:41.310259+1100 TheBooks3[63380:3534819] [si_destination_compare] socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL) failed: Operation not permitted
[2023-01-13T21:24:41.311Z Connection-1 severe] Unable to connect socket: Error code: -9989(0x-2705), Operation not permitted
DEBUG: Open connection failed
Database connection attempted
DEBUG: AccessDataBase.deinit
- with host = "127.0.0.1"
DEBUG: We got to here
[2023-01-13T21:27:35.028Z Connection-1 severe] Unable to connect socket: Error code: -9989(0x-2705), Operation not permitted
DEBUG: Open connection failed
Database connection attempted
DEBUG: AccessDataBase.deinit