skip to Main Content

I am reinstalling Apache Age and when i am following the Age github doucmentation guide to install Apache Age. Everthing is working fine till that command.

cd age/

install

sudo make PG_CONFIG=/home/imran/age_installation/pg/postgresql-11.18/bin/pg_config install

install check

make PG_CONFIG=/home/imran/age_installation/pg/postgresql-11.18/bin/pg_config installcheck
cd postgresql-11.18/

intitialization

bin/initdb demo

After the intiliaztion command, i am getting this output.

Success. You can now start the database server using: bin/pg_ctl -D demo -l logfile start

Now when i run this command:

bin/pg_ctl -D demo -l logfile start

I am getting this unexpected output:

waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.

While i am expecting this output that the server will be started.

The log file is as follows:

023-04-14 20:24:19.807 PKT [23717] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2023-04-14 20:24:19.807 PKT [23717] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-04-14 20:24:19.807 PKT [23717] WARNING:  could not create listen socket for "localhost"
2023-04-14 20:24:19.807 PKT [23717] FATAL:  could not create any TCP/IP sockets
2023-04-14 20:24:19.807 PKT [23717] LOG:  database system is shut down
2023-04-14 20:25:11.149 PKT [23724] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2023-04-14 20:25:11.149 PKT [23724] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-04-14 20:25:11.150 PKT [23724] WARNING:  could not create listen socket for "localhost"
2023-04-14 20:25:11.150 PKT [23724] FATAL:  could not create any TCP/IP sockets
2023-04-14 20:25:11.150 PKT [23724] LOG:  database system is shut down
2023-04-14 20:25:58.465 PKT [23733] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2023-04-14 20:25:58.465 PKT [23733] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-04-14 20:25:58.465 PKT [23733] WARNING:  could not create listen socket for "localhost"
2023-04-14 20:25:58.465 PKT [23733] FATAL:  could not create any TCP/IP sockets
2023-04-14 20:25:58.465 PKT [23733] LOG:  database system is shut down

4

Answers


  1. I can see that the issue is persisting because the server cannot be started since the port which youre trying to bind to is already in the use . So I recommend you to do following things:

    • First of all try to stop the PostgreSQL running server which might be running on your system. For stopping it you can use the pg_ctl command like:

    pg_ctl stop -D /path/to/postgresql/data

    After you have stopped it , you can then try to start AGE server again.

    • The other solution I will recommend is to change the binding port number by giving a specified port number to you command. For example:

    pg_ctl -D demo -l logfile -o "-p 5433" start

    What this will do it will start the server on the designated 5433 port than on 5432

    I hope these recommendations solve your issue.

    Login or Signup to reply.
  2. This error is because, the port 5432 is occupied. To free up that port, find the process ID (PID) running on port 5432 as below:

    lsof -i tcp:5432   
    

    This will return all the processes running on 5432 along with their PIDs. Next, kill the process(es) by running:

    sudo pkill -9 PID     //Replace the PID with the PID returned by above command. 
    

    Run the server again

    bin/pg_ctl -D demo -l logfile start
    
    Login or Signup to reply.
  3. This error occurs when another process is already using the port you are trying to use (5432 by default). The most likely reason is that you have already started the Postgres sever before and trying to start again.
    You can find which process is using the port using the following command.

    lsof -i :5432
    

    You can then kill them directly using kill PID or pkill PROCESS_NAME or killall PROCESS_NAME command, but this may result in some other process to misbehave so it is best to close the processes properly.

    As a temporary solution, you can also try to run the server on a different port. You can use one of these commands to run postgres on a different port.

    pg_ctl -o "-F -p 5450" start
    postgres -p 5450
    

    And if you want to run the server permanently on a different port, you can change the port number in postgresql.conf file. There should be a line like

    port = 5432
    

    Change that to whatever you want, and try to start again.

    Login or Signup to reply.
  4. From the log file, another postmaster or postgres server is running on the port 5432. You should stop that server but if you cannot remember starting a server then you can run lsof -i :5432; this shows you the process running on that port. After then, kill that process by using sudo pkill PID (PID is the process id which is returned on the command line after running the initial command). Now you can run the command to start the server again. If this doesn’t work, you should consider starting the server on another port number.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search