OK, I ran mongod
and from the error output it appeared that the culprit was /tmp/mongodb-27017.sock
from the following error:
{"t":{"$date":"2025-02-03T23:13:06.391+00:00"},"s":"E", "c":"NETWORK", "id":23024, "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Permission denied"}}
So I removed the socket file, uninstalled and reinstalled mongodb, and now mongosh
connects as expected.