22

I am attempting to install Postgres 9.3 on Ubuntu 14.04 and I am getting an irksome error on startup. Here's what I'm seeing:

$ sudo service postgresql restart
* Restarting PostgreSQL 9.3 database server
* Error: could not exec /usr/lib/postgresql/9.3/bin/pg_ctl /usr/lib/postgresql/9.3/bin/pg_ctl start -D /var/lib/postgresql/9.3/main -l /var/log/postgresql/postgresql-9.3-main.log -s -o  -c config_file="/etc/postgresql/9.3/main/postgresql.conf" : [fail]

So I checked the log file with this output:

 2015-01-05 21:50:05 EST LOG:  database system was shut down at 2015-01-05 21:50:03 EST
 2015-01-05 21:50:05 EST LOG:  database system is ready to accept connections
 2015-01-05 21:50:05 EST LOG:  autovacuum launcher started
 2015-01-05 21:50:06 EST LOG:  incomplete startup packet
 2015-01-05 21:51:22 EST ERROR:  syntax error at or near "exit" at character 1
 2015-01-05 21:51:22 EST STATEMENT:  exit;

"Incomplete startup packet" seems to be the culprit but I am having trouble finding info out there on what might be going on, so I thought I would ask. Thanks in advance.

0

2 Answers 2

24

There are 3 different items in this question:

  • Incomplete startup packet occuring at server start is inconsequential, you may ignore it. Read Incomplete startup packet help needed (in pgsql-general mailing-list) for more.

  • syntax error at or near "exit" at character 1 means that a client issued exit as if it was an SQL statement.

  • The could not exec error when issuing service postgresql restart looks like a serious installation problem but it's contradicted by the log entry database system is ready to accept connections meaning that the server started up just fine.

4
  • Your response "looks like a serious installation problem" prompted me to do some more research on how to entirely delete Postgres and reinstall. I found this article which was helpful in removing every trace of Postgres prior to reinstall and worked great. Commented Jan 6, 2015 at 13:45
  • 10
    one of the possible causes of "Incomplete startup packet" is when a TCP connection is made to the postgresql port 5432, and the immediately closed. This can happen when a monitoring program is configured to check the port, but not to run a SQL command.
    – Tom
    Commented May 1, 2016 at 1:03
  • Nicely spotted @TomH, that bit me today. Is there any other way to check that the database is accepting connections? MySQL has mysqladmin --wait=30 ping
    – Yarek T
    Commented May 10, 2019 at 16:16
  • 1
    @YarekT: pg_isready - check the connection status of a PostgreSQL server Commented May 10, 2019 at 18:07
-2

Maybe your iptables are dropping packages on port 5432.
Consider adding the following rule to your iptables:

# sudo iptables -A INPUT -p tcp -m tcp --dport 5432 -j ACCEPT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.