Intermittent "111 - Connection Refused" on backend

I have two linodes, www1 (web server) and db1 (db server). www1 runs Apache/PHP, db1 runs mysqld and searchd (Sphinx search daemon). www1 talks to mysqld and searchd on db1 over the backend network. Most of the time this works fine, however after there has been no network traffic for ~2 min, the first attempt to connect (that can be either mysqld or searchd) will consistently get a errno=111 "Connection Refused" error. Subsequent connects then work fine again. Since the same thing happens consistently for either mysqld and searchd, I assume it's not their fault. Also, if I tunnel into db1 through SSH I can access both mysqld and searchd and never get this problem. And if I use telnet to connect from www1 to mysqld/searchd on db1, I observe the same thing - get a "connection refused" error the first time (sometimes the second time, too actually), afterwards it connects fine. So my wild guess is that the problem is with db1's firewall settings. Here's the rules I use on db1:

Incoming packets (INPUT)

Accept If input interface is lo

Reject If destination is 127.0.0.0/255.0.0.0 and input interface is not lo

Accept If state of connection is RELATED,ESTABLISHED

Accept If protocol is TCP and source is 192.168.133.238 and input interface is eth1 and destination port is 3306 and state of connection is NEW

Accept If protocol is TCP and source is 192.168.133.238 and input interface is eth1 and destination port is 3312 and state of connection is NEW

Accept If protocol is TCP and input interface is eth0 and destination port is 52181 and state of connection is NEW

Accept If protocol is TCP and input interface is eth0 and destination port is 22777 and state of connection is NEW

Accept If protocol is ICMP and ICMP type is 8

Reject Always

Forwarded packets (FORWARD)

Reject Always

Outgoing packets (OUTPUT)

Accept Always

Maybe it's not the firewall, but something else though. Any clues would be appreciated.

Thanks so much!

Markus

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct