PostgreSQL — could not bind ipv4 socket: cannot assign requested address

Postgreql, Unix

Jebus. This one wasted 4 hours and was a terrible terrible experience. Absolute frustration.

If I can understand all of this one day, I will be extremely proud. People who work on these systems are ridiculous geniuses.

I was getting ready to move our software to the live server but for some reason the postgresql server died on it. Checking up on logs shows that the server lost available memory and oom-killer, well, killed stuff.

So, upon restarting, postgresql would not start, giving me this error: could not bind apv4 socket: cannot assign requested address

Is postmaster listening on 5432? no its not lsof -i :5432 shows nothing. So whats up?

After reading posts after posts (most people suggest “you are probably already running postmaster”) I came upon an obscure reference to localhost not being resolvable.

ping localhost… nothing happens. There’s our problem.

Turns out its been running fine for months w/o a restart, and I had a wrong settings in /etc/network/interfaces

I had my iptables rules not auto-loading because I spelled the script ‘itables’ instead of ‘iptables’.

So.. bottom line? check to see if you can ping localhost.


8 thoughts on “PostgreSQL — could not bind ipv4 socket: cannot assign requested address

  1. It is now 2017, and this is as relevant as it get. In my case it was a configuration mistake that didn’t bring lo up, but thinking that localhost wasn’t accessible was not in my list of things to check.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s