createuser: error: could not connect to database template1: could not connect to server: No such file or directoryIs the server running locally and acceptingconnections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? code example

Example: 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.5432"?

$ rm /usr/local/var/postgres/postmaster.pid
$ brew services restart postgresql

# Think to restart your terminal (cmd + q on macOS)