pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
could not bind IPv4 address "127.0.0.1": Address already in use
3+ messages / 2 participants
[nested] [flat]

* could not bind IPv4 address "127.0.0.1": Address already in use
@ 2023-03-08 01:28  Siddharth Jain <siddhsql@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Siddharth Jain @ 2023-03-08 01:28 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi All,

I am trying to run Postgres 14 on a Mac OS. I installed Postgres from EDB
and ran initdb and it gave me this:

❯ initdb
The files belonging to this database system will be owned by user "xxx".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/pgsql/14/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... America/Los_Angeles
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/pgsql/14/data -l logfile start

But when I try to start the server I get this:

❯ pg_ctl -D /var/lib/pgsql/14/data start
waiting for server to start....2023-03-07 17:16:43.226 PST [25925] LOG:
 starting PostgreSQL 14.7 on x86_64-apple-darwin20.6.0, compiled by Apple
clang version 12.0.0 (clang-1200.0.32.29), 64-bit
2023-03-07 17:16:43.228 PST [25925] LOG:  could not bind IPv6 address
"::1": Address already in use
2023-03-07 17:16:43.228 PST [25925] HINT:  Is another postmaster already
running on port 5432? If not, wait a few seconds and retry.
2023-03-07 17:16:43.228 PST [25925] LOG:  could not bind IPv4 address
"127.0.0.1": Address already in use
2023-03-07 17:16:43.228 PST [25925] HINT:  Is another postmaster already
running on port 5432? If not, wait a few seconds and retry.
2023-03-07 17:16:43.228 PST [25925] WARNING:  could not create listen
socket for "localhost"
2023-03-07 17:16:43.228 PST [25925] FATAL:  could not create any TCP/IP
sockets
2023-03-07 17:16:43.229 PST [25925] LOG:  database system is shut down
 stopped waiting
pg_ctl: could not start server
Examine the log output.

I ran:

 ~/ netstat -ln -p tcp | grep 5432

and there is no output. I also tried:

❯ pg_ctl status
pg_ctl: no server running

What is wrong here and how to fix?

S.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: could not bind IPv4 address "127.0.0.1": Address already in use
@ 2023-03-08 04:28  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Siddharth Jain <siddhsql@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2023-03-08 04:28 UTC (permalink / raw)
  To: Siddharth Jain <siddhsql@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

Siddharth Jain <siddhsql@gmail.com> writes:
> But when I try to start the server I get this:

> 2023-03-07 17:16:43.228 PST [25925] LOG:  could not bind IPv6 address
> "::1": Address already in use
> 2023-03-07 17:16:43.228 PST [25925] HINT:  Is another postmaster already
> running on port 5432? If not, wait a few seconds and retry.
> 2023-03-07 17:16:43.228 PST [25925] LOG:  could not bind IPv4 address
> "127.0.0.1": Address already in use
> 2023-03-07 17:16:43.228 PST [25925] HINT:  Is another postmaster already
> running on port 5432? If not, wait a few seconds and retry.

That's pretty clear I think: the ports are already bound.

> I ran:
>   netstat -ln -p tcp | grep 5432
> and there is no output.

This is the wrong incantation for this purpose.  Try

netstat -an -p tcp | grep 5432

I expect you'll see a couple of ports in LISTEN state.  Unfortunately,
netstat is not much help at locating the processes listening to such
ports.  This might be more help:

lsof -n | grep 5432

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: could not bind IPv4 address "127.0.0.1": Address already in use
@ 2023-03-08 16:45  Siddharth Jain <siddhsql@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Siddharth Jain @ 2023-03-08 16:45 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org

Thanks Tom. found the problem.

On Tue, Mar 7, 2023 at 8:28 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Siddharth Jain <siddhsql@gmail.com> writes:
> > But when I try to start the server I get this:
>
> > 2023-03-07 17:16:43.228 PST [25925] LOG:  could not bind IPv6 address
> > "::1": Address already in use
> > 2023-03-07 17:16:43.228 PST [25925] HINT:  Is another postmaster already
> > running on port 5432? If not, wait a few seconds and retry.
> > 2023-03-07 17:16:43.228 PST [25925] LOG:  could not bind IPv4 address
> > "127.0.0.1": Address already in use
> > 2023-03-07 17:16:43.228 PST [25925] HINT:  Is another postmaster already
> > running on port 5432? If not, wait a few seconds and retry.
>
> That's pretty clear I think: the ports are already bound.
>
> > I ran:
> >   netstat -ln -p tcp | grep 5432
> > and there is no output.
>
> This is the wrong incantation for this purpose.  Try
>
> netstat -an -p tcp | grep 5432
>
> I expect you'll see a couple of ports in LISTEN state.  Unfortunately,
> netstat is not much help at locating the processes listening to such
> ports.  This might be more help:
>
> lsof -n | grep 5432
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2023-03-08 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 01:28 could not bind IPv4 address "127.0.0.1": Address already in use Siddharth Jain <siddhsql@gmail.com>
2023-03-08 04:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-03-08 16:45   ` Siddharth Jain <siddhsql@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox