0
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

I tried to follow PostgreSQL: Why psql can't connect to server? but after typing

sudo service postgresql start

I get:

 * Starting PostgreSQL 14 database server                                                                                * Error: /usr/lib/postgresql/14/bin/pg_ctl /usr/lib/postgresql/14/bin/pg_ctl start -D /var/lib/postgresql/14/main -l /var/log/postgresql/postgresql-14-main.log -s -o  -c config_file="/etc/postgresql/14/main/postgresql.conf"  exited with status 1:
2021-12-13 10:54:29.791 CET [180] LOG:  starting PostgreSQL 14.1 (Ubuntu 14.1-2.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-12-13 10:54:29.797 CET [180] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2021-12-13 10:54:29.798 CET [180] WARNING:  could not create listen socket for "localhost"
2021-12-13 10:54:29.798 CET [180] FATAL:  could not create any TCP/IP sockets
2021-12-13 10:54:30.039 CET [180] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.

After: sudo find /tmp/ -name .s.PGSQL.5432 -> nothing After: sudo systemctl status postgresql -> System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

How to fix it? I am trying to install chirpstack LoraWAN server

kometen
  • 6,536
  • 6
  • 41
  • 51

1 Answers1

2

I had the same problem. It seems like you are using Ubuntu in wsl3 like me.

ps -p 1 -o comm=

If you get init after the above command, then it means your ubuntu uses SysV instead of systemd. You can use the below commands.

sudo service postgresql status
sudo service postgresql start
sudo service postgresql stop
cursorrux
  • 1,382
  • 4
  • 9
  • 20
min
  • 21
  • 3