It’s a bit of a common question (in the Ruby on Rails world, at least!). I came across this issue this morning when I copied an existing ThinkingSphinx yml file from a working system.

Symptoms:

Running rake ts:rebuild would rebuild the database, but would not start the daemon. The error message received is two lines of

Failed to start searchd daemon. Check /home/{myusername}/dev_rails/{my project name}/log/searchd.log.

When I searched the log folder, the file searchd.log was not there, so there were no more clues as to what went wrong.

A Google search found this posting referring to the same issue. Following the instructions there, I tried to start the daemon manually.

searchd --pidfile --config config/development.sphinx.conf

Using that command, I got the same results as the poster in the thread;

Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew Aksyonoff

using config file 'config/development.sphinx.conf'...
listening on 127.0.0.1:9312
bind() failed on 127.0.0.1, retrying...
bind() failed on 127.0.0.1, retrying...
bind() failed on 127.0.0.1, retrying...
bind() failed on 127.0.0.1, retrying...

That gave me a clue, which turned out to be the answer…

The Solution

My sphinx.yml file had the following content for the Development section;

development:
 enable_star: true
 morphology: stem_en
 html_strip: true
 min_infix_len: 3
 port: 9310
 sql_range_step: 10000000

 

When I checked the file development.sphinx.conf, the searchd section had the following;

searchd
{
 listen = 127.0.0.1:9312
....etc

 

The issue was the port number. I edited the development.sphinx.conf file to listen on port 9310 instead of 9312, restarted the daemon with the command rake ts:rebuild (because rake ts:start didn’t work at this point), and all is well – I’m back in business.