1

I have a server with 2 networking interfaces - global on eth0, and local on eth1 with IP like 10.181.xx.xx. Running Ubuntu 16.04.

I set up PostgreSQL to listen on this local address, so another server from the network can access it.

The issue is when I reboot DB server, PostgreSQL can not bind to this local address. Having this in postgresql.log:

2016-07-01 15:06:09 GMT LOG:  could not bind IPv4 socket: Cannot assign   requested address
2016-07-01 15:06:09 GMT HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-07-01 15:06:09 GMT WARNING:  could not create listen socket for "10.181.xx.xx"

After doing service postgresql restart all is working.

How can I make Postgres wait until eth1 is up after reboot and bind to it?

2 Answers 2

3

Looked into /var/log/syslog and figured out that it was an issue with systemd startup sequence.

Added

After=network-online.target

line into /lib/systemd/system/[email protected] to [Unit] section

So it looks like that:

[Unit]
Description=PostgreSQL Cluster %i
ConditionPathExists=/etc/postgresql/%I/postgresql.conf
PartOf=postgresql.service
ReloadPropagatedFrom=postgresql.service
Before=postgresql.service
After=network-online.target

All started working - PostgreSQL now loads after network is online.

2
0

I faced with the same problem and solution from accepted answer worked for me. However, I did some further research and found out that in my case the problem appears only if I explicitly specify IP address in postgresql.conf:

listen_addresses = '10.181.xx.xx'

When I modified config to listen all addresses, the problem disappeared:

listen_addresses = '*'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .