Postgre install failed


Hi. I’m noob in postgre and nix. I tried installing postgre with the expression “$nix-env -iA nixos.postgresql100”
I found at, using option postgresql-10.6. All right.

Following the postgre manual I tried to create a DB with “$ createdb mydb”, but I got:

‘createdb: could not connect to database postgres: 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”?’

According to the manual this is a problem. How do I install? Me doing it wrong?


Do you run NixOS, or just Nix inside some other Linux distribution?

If you run NixOS, then you need to add services.postgresql.enable = true; to your /etc/nixos/configuration.nix, and run nixos-rebuild switch. This will activate the PostgreSQL service (as opposed to just fetching and installing the PostgreSQL software), so you’ll actually have the PostgreSQL server running.


I’m using NixOS. I’ll try this and come back.

Thank you very much.