FATAL: syntax error in file “/var/lib/pgsql/data/postgresql.conf” line 237, near token “””
On a recent installation of PostgreSQL on CentOS Linux I had some issues after making some configuration changes. I have a basic template of changes I make to Postgres after initial installation and then I restart the PostgreSQL server. This time when restarting Postgres it failed as shown below.
Error Restarting PostgreSQL Server On Linux:
[root@adev data]# /etc/init.d/postgresql restart Stopping postgresql service: [ OK ] Starting postgresql service: [FAILED]
So after initial installation the server was running fine but after the configuration changes I made the postgresql database server would not start. In any scenario similar to this the best place to begin the search for the problem is the pgstartup.log file located in the /var/lib/pgsql/ directory by default. When looking at this file using “less” it was easy to see the last couple of lines pointed me directly to the problem in a file I had just modified. The last couple lines of the pgstartup.log file are listed below.
Errors In pgstartup.log File:
Success. You can now start the database server using: /usr/bin/postgres -D /var/lib/pgsql/data or /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start FATAL: syntax error in file "/var/lib/pgsql/data/postgresql.conf" line 236, near token """
As you can see above the last line in the pgstartup.log file shows the error is on line 236 of the postgresql.conf file. Upon opening the Postgres configuration file and viewing line 236 I noticed the error right away. In the log statements I modified I used double quotes instead of single quotes for each configuration item. Below I show the configuration file lines I modified first with the incorrect double quotes and then second with the single quotes which is how each line should be.
Error: postgresql.conf Variables Using Double Quotes:
log_line_prefix = "%m" log_directory = "pg_log" log_filename = "postgresql-%a.log" log_destination = "stderr"
Correct: postgresql.conf Variables Using Single Quotes:
log_line_prefix = '%m' log_directory = 'pg_log' log_filename = 'postgresql-%a.log' log_destination = 'stderr'
After correcting each line in the postgresql.conf file to use single quotes instead of double quotes PostgreSQL started without issue as shown below.
Start PostgreSQL On CentOS Linux:
[root@adev pgsql]# /etc/init.d/postgresql start Starting postgresql service: [ OK ]
Make sure to always use single quotes instead of double quotes in the postgresql.conf configuration file.