How can I connect to a local PostgreSQL database server on Ubuntu Linux from a .NET Core application with Npgsql?
I'm using this connection string on Windows:
Server=localhost;User ID=webdev;Password=webdev;Database=dbname
I'm using this shell command on Linux:
psql dbname
Now I've tried with this connection string on Linux:
Server=/var/run/postgresql;Database=dbname
But I got this error:
Cannot assign requested address /var/run/postgresql/.s.PGSQL.5432
If I try this connection string on Linux:
Server=localhost;Database=dbname
Then I get this error:
Connection refused
How does this work? I'd like to take advantage of password-less login from the same local system account.
127.0.0.1orlocalhostand updatepg_hbato accept connection from there with trust. You can also use peer if there is a user locally. - 123psqlcommand can connect to the server locally just fine. Why can't Npgsql do the same? - ygoepsqland by whom the database is owned. I don't know whether the socket path is correct.psql --helptold it to me as its default, so I took it. Actually I'd rather not specify anything at all, just like forpsql. But Npgsql documents that the Host/Server parameter is required. - ygoe