Postgresapp: Startup fails "LOG: could not bind IPv4 socket: Can't assign requested address"

Created on 27 Dec 2015  路  8Comments  路  Source: PostgresApp/PostgresApp

I just downloaded version 9.4.5 on Mac OS X El Capitan (10.11.2) and startup fails with:

LOG: could not bind IPv4 socket: Can't assign requested address
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets

As far as I can tell, there is no PostgreSQL process running (using "ps") and no process listening on port 5432 (using Network Utility, lsof and netstat). I used to have a 9.4.beta PostgresApp but followed the instructions to remove the app and data dir.

What else should I look at? Any suggestions? Anyone else have this problem?

Thanks,

Doug

Most helpful comment

I just checked sys/errno.h, and the error message "Can't assign requested address" corresponds to the error code EADDRNOTAVAIL. The man page for bind(2) explains this error code as "The specified address is not available from the local machine."

So for some reason your computer thinks it doesn't have an address named "localhost:5432".

The most likely reason for this is that you broke the localhost entry in your /etc/hosts file. Here's what should be in that file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

OS X is somewhat picky about the format of this file, so make sure you have no syntax errors in there. Use an editor that shows the difference between tabs, spaces, and non-breaking spaces when editing it.

All 8 comments

I just checked sys/errno.h, and the error message "Can't assign requested address" corresponds to the error code EADDRNOTAVAIL. The man page for bind(2) explains this error code as "The specified address is not available from the local machine."

So for some reason your computer thinks it doesn't have an address named "localhost:5432".

The most likely reason for this is that you broke the localhost entry in your /etc/hosts file. Here's what should be in that file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

OS X is somewhat picky about the format of this file, so make sure you have no syntax errors in there. Use an editor that shows the difference between tabs, spaces, and non-breaking spaces when editing it.

I hope that your problem is fixed! Since I didn't hear back, I'm closing this issue. If the problem persists, feel free to reopen!

Hi Jakob,

Sorry for my delayed response and huge kudos for your spot-on insight. I should have looked at /etc/hosts before opening this issue. Turns out /etc/hosts was empty (i.e. zero bytes). I found an /etc/hosts~orig that contained exactly what you said to check so just copied it to /etc/hosts and PostgresApp started lickety-split. I don't remember emptying hosts or creating hosts~orig ;-) but a quick Google-search failed to turn up any smoking guns (e.g. upgrading OSX or installing some App). Anyway, problem solved & thanks for your help!

I encounter the same problem, while i can't solve it even though i check my /etc/hosts is right.
It takes me very long time and i just don't know what is the problem is.
Any help is appreciated, thanks.

@Troland please open a new issue, including the following info in detail:

1) What are you trying to do?
2) What error messages are displayed?
3) What version of OS X do you use?
4) Do you use any firewall, network filter, or any dev tools that change your network configuration, or did you install any kernel extensions?

@jakob ok, it just drive me crazy and i'd open a new issue.

@jakob I just open the new issue, check plz.

@jakob wow, thank you so much! Several hours of head scratching for such a simple issue...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

songproducer picture songproducer  路  10Comments

wellsoliver picture wellsoliver  路  4Comments

beckmx picture beckmx  路  7Comments

markcerqueira picture markcerqueira  路  13Comments

JacobEvelyn picture JacobEvelyn  路  10Comments