Issue with Starting Postgresql server RHEL/CentOS 6

After I've installed postgresql on my Redhat enterprise Linux 6, it failed to start:

# service postgresql start
Starting postgresql service:                               [FAILED]

After I checked the postgresql logs, 

# vim /var/lib/pgsql/pgstartup.log

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".

fixing permissions on existing directory /var/lib/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

    /usr/bin/postgres -D /var/lib/pgsql/data
    /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

LOG:  could not translate host name "localhost", service "5432" to address: Name or service not known
WARNING:  could not create listen socket for "localhost"
FATAL:  could not create any TCP/IP sockets

I noticed it seems something goes wrong with "localhost" name resolution that server cannot create listen socket for "localhost", 

Then I remembered, in my /etc/hosts I have commented out the localhost entry for some unknown reasons and "ping localhost" returns no result: 

# cat /etc/hosts
#       localhost.localdomain   localhost.localdomain   localhost4      localhost4.localdomain4 localhost
::1     localhost.localdomain   localhost.localdomain   localhost6      localhost6.localdomain6 localhost     

Once I removed the comment for line, postgresql started successfully:

# service postgresql start
Starting postgresql service:                               [  OK  ]


Popular posts from this blog

Linux and AIX user non expiry and force password change at first login

Rebuild your new Yum repository after changing the packages

Running Docker Wildfly/JBoss Application Server in Debug mode via Eclipse