I'm trying to start my development instance of Postgresql on my local machine. I'm running Windows 10 Home (build 18363.900), with a WSL Ubuntu 18.04.4 LTS. I've tried a number of things:
$ sudo systemctl start postgresql
System has not been booted with systemd as init system (PID 1). Can't operate.
(same with restart)
$ sudo /etc/init.d/postgresql start
* Starting PostgreSQL 10 database server * Error: /usr/lib/postgresql/10/bin/pg_ctl /usr/lib/postgresql/10/bin/pg_ctl start -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-10-main.log -s -o -c config_file="/etc/postgresql/10/main/postgresql.conf" exited with status 1:
2020-06-16 20:36:37.334 PDT [8106] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2020-06-16 20:36:37.334 PDT [8106] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-06-16 20:36:37.335 PDT [8106] WARNING: could not create listen socket for "localhost"
2020-06-16 20:36:37.335 PDT [8106] FATAL: could not create any TCP/IP sockets
2020-06-16 20:36:37.335 PDT [8106] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.
(same for postgres)
$ sudo service postgresql start
* Starting PostgreSQL 10 database server * Error: /usr/lib/postgresql/10/bin/pg_ctl /usr/lib/postgresql/10/bin/pg_ctl start -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-10-main.log -s -o -c config_file="/etc/postgresql/10/main/postgresql.conf" exited with status 1:
2020-06-16 20:37:19.907 PDT [8140] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2020-06-16 20:37:19.907 PDT [8140] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-06-16 20:37:19.907 PDT [8140] WARNING: could not create listen socket for "localhost"
2020-06-16 20:37:19.907 PDT [8140] FATAL: could not create any TCP/IP sockets
2020-06-16 20:37:19.908 PDT [8140] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.
and just in case
$ sudo service postgres start
postgres: unrecognized service
service does me no better.
Stop, of course, works as expected:
$ sudo service postgresql stop
* Stopping PostgreSQL 10 database server [ OK ]
but
sudo service postgresql restart
gives the same as start.
Status also gives me an expected result:
$ sudo service postgresql status
10/main (port 5432): down
My /etc/hosts reads
# This file is automatically generated by WSL based on the Windows hosts file:
# %WINDIR%\System32\drivers\etc\hosts. Modifications to this file will be overwritten.
127.0.0.1 localhost
127.0.1.1 DESKTOP-LKMEB17.localdomain DESKTOP-LKMEB17
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
which leads me to believe that changes to /etc/hosts won't help
I've tried to kill postmaster, but its pid keeps changing every time I try to kill it, which leads me to believe its spinning
$ ps -ef | grep postmaster | awk '{print $2}'
8151
$ ps -ef | grep postmaster | awk '{print $2}'
8154
Shooting in the dark to kill the process doesn't work either, confusingly
$ ps -ef | grep postmaster
me 298 116 0 15:35 tty3 00:00:00 grep postmaster
$ kill -9 300
-bash: kill: (300) - No such process
$ kill -9 298
-bash: kill: (298) - No such process
$ kill -9 299
-bash: kill: (299) - No such process
$ kill -9 301
-bash: kill: (301) - No such process
$ ps -ef | grep postmaster
me 300 116 0 15:36 tty3 00:00:00 grep postmaster
Which is weird -- I killed pid 300
Surprisingly, nothing seems to be listening on localhost:5432
$ curl localhost:5432
curl: (52) Empty reply from server
I'm not sure where to go from here.