ruby-on-rails 无法创建任何TCP/IP套接字(有时候postgresql不会启动,但第二天会再次启动)[关闭]

zte4gxcn  于 2023-04-13  发布在  Ruby
关注(0)|答案(1)|浏览(249)

**已关闭。**此问题为not about programming or software development。当前不接受答案。

此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site主题相关,您可以留下评论以解释在何处可以回答此问题。
昨天关门了。
Improve this question
这是我的wsl -l -v

NAME      STATE           VERSION
* Ubuntu    Stopped         2

lsb_release -a输出:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

pg_config --version输出:

PostgreSQL 14.6 (Ubuntu 14.6-0ubuntu0.22.04.1)

我在前一天遇到了这个问题,我无法启动或重新启动postgresql,并会输出以下内容:
sudo service postgresql startsudo service postgresql restart输出:

* 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:
2023-03-17 21:08:03.100 CST [1028] LOG:  starting PostgreSQL 14.6 (Ubuntu 14.6-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, 64-bit
2023-03-17 21:08:03.103 CST [1028] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2023-03-17 21:08:03.103 CST [1028] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-03-17 21:08:03.103 CST [1028] WARNING:  could not create listen socket for "localhost"
2023-03-17 21:08:03.103 CST [1028] FATAL:  could not create any TCP/IP sockets
2023-03-17 21:08:03.106 CST [1028] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.

我检查了日志输出,它显示了以下内容:

2023-03-18 17:18:34.718 CST [337] LOG:  starting PostgreSQL 14.6 (Ubuntu 14.6-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu,>2023-03-18 17:18:34.721 CST [337] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2023-03-18 17:18:34.721 CST [337] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds>2023-03-18 17:18:34.721 CST [337] WARNING:  could not create listen socket for "localhost"
2023-03-18 17:18:34.721 CST [337] FATAL:  could not create any TCP/IP sockets
2023-03-18 17:18:34.723 CST [337] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.

我试过这个:sudo service postgresql status但它会显示主机关闭。sudo service postgresql stop也会停止服务器。
ps -ef | grep postgres输出:

ann       211    60  0 20:27 pts/0    00:00:00 grep --color=auto postgres

我也已经从这个文件sudo nano /etc/postgresql/14/main/postgresql.conf更改了localhost:
从:listen_addresses: localhost到:listen_addresses = '*'
我已经检查过它正在监听Port: 5432。我甚至试着重新启动电脑,没有运气。我更新Windows 11后开始得到这些错误。
这已经发生在前一天,然而,在从Powershell退出Ubuntu终端几次尝试后,它只会启动postgresql。昨天,当我尝试它时,所有这些错误都出现了。现在,当我尝试用sudo service postgresql start启动postgresql时,PostgreSQL数据库服务器在主端口5432上启动没有任何问题。我正在用这个开发一个Ruby on Rails应用程序。

tct7dpnv

tct7dpnv1#

尝试在Windows上使用netstat -nab并检查在您的端口上侦听的内容。对我来说,它是Windows IP Helper Service(iphlpsvc),它阻塞了所有端口。我使用netsh将端口转发到wsl2。
参见:https://superuser.com/questions/1660118/windows-ip-helper-service-iphlpsvc-is-it-possible-to-change-port

相关问题