"Could not create IPv6 socket" postgresql standby error

9,431

Solution 1

This happens when IPv6 is not enabled in the kernel but IPv6 addresses are advertised somewhere.

Sometimes localhost in /etc/hosts designates both 127.0.0.1 (IPv4) and ::1 (IPv6). In which case you may remove the IPv6 alias to avoid that kind of error.

The stats collector (a separate process launched by PostgreSQL) uses the hard-coded name localhost, so this problem would make it fail to start with the mentioned error message. However, this shouldn't prevent PostgreSQL itself to start.

If * happens to include problematic IPv6 addresses, you may solve the problem by being selective in listen_addresses (which is good practice anyway):

listen_addresses=127.0.0.1,10.10.10.1 # add other interfaces if needed

Solution 2

To disable the IPv6 error, you have to do following steps.

  1. paste the following code in this file (/etc/sysctl.conf)

    net.ipv6.conf.all.disable_ipv6 = 1

  2. In postgresql.conf file change the listen address to 0.0.0.0

    listen_address ='0.0.0.0'

That's it and restart the postgreSQL service.

Share:
9,431

Related videos on Youtube

Alex
Author by

Alex

newbie postgresql database developer

Updated on September 18, 2022

Comments

  • Alex
    Alex over 1 year

    I'm trying to create Postgresql 9.1 hot-standby using following steps:

    1. Configured 2 virtual linux machines. Master's ip: 10.10.10.1, Standby's ip: 10.10.10.2. Ping test passed.
    2. Restored the same db backup on both.
    3. Edited pg_hba on master. Added line:

      host   replication   postgres   10.10.10.2/32   md5
      
    4. Edited Master's postgresql.conf:

      listen_address = '*'
      wal_level = hot_standby
      max_wal_senders = 3
      
    5. Created recovery.conf on Standby:

      standby_mode = 'on'
      primary_conninfo = 'host=10.10.10.1'
      

    After adding recovery.conf I fail to start Standby server. In startup log I get an error:

    > could not create IPv6 socket
    

    Did I missed something?

  • Otheus
    Otheus almost 9 years
    Thanks for your answer, Daniel. My system has no IPv6 enabled anywhere, nor are there ipv6 addresses in the hosts file or elsewhere, yet I still see this. I don't want to set listen_addresses for a variety of reasons. Any ideas where the IPv6 is getting picked up?