Postgres database not starting on port 5432 despite no interfering process, but works on other ports

huangapple go评论52阅读模式
英文:

Postgres database not starting on port 5432 despite no interfering process, but works on other ports

问题

问题

当我尝试通过Postgres.app在端口5432上启动Postgres 15数据库时,它不起作用,无法启动。我尝试了我能力范围内的一切来解决这个问题,但似乎无法弄清楚。

这是弹出的失败消息,我在服务器日志中收到以下错误:

2023-04-19 00:10:05.163 PDT [35503] LOG:  listening on IPv6 address "::1", port 5432
2023-04-19 00:10:05.163 PDT [35503] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-04-19 00:10:05.163 PDT [35503] LOG:  could not bind Unix address "/tmp/.s.PGSQL.5432": Address already in use
2023-04-19 00:10:05.163 PDT [35503] HINT:  Is another postmaster already running on port 5432?
2023-04-19 00:10:05.163 PDT [35503] WARNING:  could not create Unix-domain socket in directory "/tmp"
2023-04-19 00:10:05.163 PDT [35503] FATAL:  could not create any Unix-domain sockets
2023-04-19 00:10:05.164 PDT [35503] LOG:  database system is shut down

注意:我没有通过Homebrew安装Postgres,如果我选择其他端口,比如5433,数据库就可以正常启动。

我做了什么

我知道你在想什么,我是否有一个运行在端口5432上的进程?

我用lsof -i :5432sudo lsof -i :5432netstat | grep "5432" | grep "LISTEN"检查过了5432端口,但终端都是空的。我希望干扰进程会出现在进程列表中,然后我只需杀死该进程以释放该端口。但是,在端口5432上确实没有进程显示。

我甚至尝试卸载并重新安装Postgres.app和Postgres,但仍然没有解决(除非我以某种方式做错了)。试图解决这个问题,已经疯狂了,一直在Google和尝试我所能做的一切。其他端口号可以工作,只是端口5432不行。而且,我没有敏感数据需要保留或保存,我只是想让我的本地Postgres在5432上工作,因为每次使用代码库时我宁愿不必更改为5433或其他端口。所以,如果有一些可以通过删除文件之类的方法来解决的方法,我愿意尝试。

感谢任何帮助!

英文:

Problem

When I tried to turn on Postgres 15 database via Postgres.app on Port 5432 specifically, it doesn't work and won't turn on. I've tried everything in my power to resolve this but I can't seem to figure this out.

This is the fail pop-up that comes up and I'm getting this error in the server log:

2023-04-19 00:10:05.163 PDT [35503] LOG:  listening on IPv6 address "::1", port 5432
2023-04-19 00:10:05.163 PDT [35503] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-04-19 00:10:05.163 PDT [35503] LOG:  could not bind Unix address "/tmp/.s.PGSQL.5432": Address already in use
2023-04-19 00:10:05.163 PDT [35503] HINT:  Is another postmaster already running on port 5432?
2023-04-19 00:10:05.163 PDT [35503] WARNING:  could not create Unix-domain socket in directory "/tmp"
2023-04-19 00:10:05.163 PDT [35503] FATAL:  could not create any Unix-domain sockets
2023-04-19 00:10:05.164 PDT [35503] LOG:  database system is shut down

Note: I did not install Postgres via Homebrew and the database starts just fine if I choose another port like 5433.

What I Did

I know what you're thinking, do I have a process running on Port 5432?

I checked that with lsof -i :5432 and sudo lsof -i :5432 and netstat | grep "5432" | grep "LISTEN" on port 5432, and the Terminal came up empty. I expected the interfering process to show up in the list of processes and then I was just going to kill that process to free up the port. However, there were literally no processes showing up on Port 5432.

I even attempted to uninstall and reinstall Postgres.app and Postgres and that still didn't resolve it (unless I somehow did that wrong). Kinda going crazy trying to solve this, been Googling and trying everything I can. Other port numbers are working, just not Port 5432. Also, I have no sensitive data to keep or save, I'm just trying to get my local Postgres to work on 5432 because I'd rather not have to change everything to 5433 or something whenever I use Postgres via codebase. So if there are some hacky ways to get this work that involves deleting stuff, I'm down.

Appreciate any help!

答案1

得分: 1

如果您查看消息,绑定TCP套接字到端口5432没有问题。问题出在创建域套接字文件上,因为已经存在一个文件/tmp/.s.PGSQL.5432。删除该文件,服务器应该能够启动。

英文:

If you look at the messages, there is no problem binding the TCP socket to port 5432. The problem is with creating the domain socket file, because there is already a file /tmp/.s.PGSQL.5432. Remove that file, and the server should start.

huangapple
  • 本文由 发表于 2023年4月20日 07:30:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76059520.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定