# Unable to connect to postgress with libPQ

**URL:** <https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906>\
**Category:** General Usage\
**Tags:** question, package, help-database, postgresql, database\
**Created:** [November 3, 2021, 6:49pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906 "2021-11-03T18:49:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 3, 2021, 6:49pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/1 "2021-11-03T18:49:44Z")

</div>

```julia
conn2 = LibPQ.Connection("dbname=postgres")

```

tells me that I can’t find

```julia
 Unix domain socket "/tmp/.s.PGSQL.5432"?

```

I’m using Ubuntu 20.04.3 LTS on an x86 Xeon machine. I’ve had the same issue with Crystal. Postgress is installed, but I need to figure out how to troubleshoot it.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [November 3, 2021, 7:15pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/2 "2021-11-03T19:15:00Z")

</div>

Do any postgres tools work? That would let you know whether it is a julia problem or a more general sysadmin problem.

For instance, can you list anything about your database with `psql` [PostgreSQL: Documentation: 13: psql](https://www.postgresql.org/docs/13/app-psql.html)

Also, this was at the top of a google search and it seems like a good starting point. [postgresql - Socket File "/var/pgsql\_socket/.s.PGSQL.5432" Missing In Mountain Lion (OS X Server) - Stack Overflow](https://stackoverflow.com/questions/13868730/socket-file-var-pgsql-socket-s-pgsql-5432-missing-in-mountain-lion-os-x-ser)

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 3, 2021, 9:01pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/3 "2021-11-03T21:01:01Z")

</div>

```julia
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "brettkknoss" does not exist

```

not sure how it created brettkknoss, I tried purging and reinstalling postgress. I think I need to change the user.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 3, 2021, 9:04pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/4 "2021-11-03T21:04:26Z")

</div>

```julia
psql -h localhost

```

requires a password, I have no idea what this password would be.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [November 3, 2021, 11:22pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/5 "2021-11-03T23:22:59Z")

</div>

It does not seem like this is Julia related. I would suggest looking up some intro tutorials on setting up postgres. I found the following two after a quick online search:

> **[1.3. Creating a Database](https://www.postgresql.org/docs/9.0/tutorial-createdb.html)**
>
> 1.3. Creating a Database # The first test to see whether you can access the database server is to try to …

> **[How to Run and Setup a Local PostgreSQL Database | Prisma](https://www.prisma.io/dataguide/postgresql/setting-up-a-local-postgresql-database)**
>
> Learn how to set up a PostgreSQL database on Windows, macOS, and Linux by following the step-by-step instructions in this practical guide.

Consider also using a simpler database, like sqlite. It is not nearly as feature rich as postgres, but it is many orders of magnitude simpler to set up.

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 3, 2021, 11:39pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/6 "2021-11-03T23:39:53Z")

</div>

thanks, is there a good community resource on Postgres?

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [November 3, 2021, 11:43pm UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/7 "2021-11-03T23:43:56Z")

</div>

I remember enjoying reading their official documentation (one of the pages above links to it), but it is a bit of a slog. If you are making a single-user desktop app, or a single-server few-users webapp you probably do not need something as heavy though. It would certainly be much easier to start with [https://github.com/JuliaDatabases/SQLite.jl](https://github.com/JuliaDatabases/SQLite.jl)

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [November 6, 2021, 12:44am UTC](https://discourse.julialang.org/t/unable-to-connect-to-postgress-with-libpq/70906/8 "2021-11-06T00:44:26Z")

</div>

OK, I think I can get a lot from SQLite. I was wanting to learn basic crud stuff, and maybe how to tie into statistics
