Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#8258 closed defect (bug) (worksforme)

Wordpress Connections not closing

Reported by: mallyo's profile mallyo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: open connections has-patch reporter-feedback
Focuses: Cc:



I've received the following from my hosting company.

I need to find a fix before they close my account, can anyone advise?

What this means is that wordpress is opening up a connection and then not closing it before the page request is complete. This leaves the connection open which in turn causes load issues. You will need to resolve this issue immediately or the account will need to be suspended again to prevent further server issues.

Can anyone help.

I have the latest version of wordpress installed 263

I've have the following mods enabled

All in One SEO Pack

Google XML Sitemaps
Permalink Redirect 2.0
SimpleTags 2.0
Simple Tags 1.57

Attachments (1)

wp-db.php.diff (321 bytes) - added by vladimir_kolesnikov 13 years ago.
Forcefully close mysql connection on shutdown

Download all attachments as: .zip

Change History (19)

#1 @jacobsantos
14 years ago

What PHP version? PHP should close the mysql connection when the page is done. However, to say it should means that it doesn't always correctly do so. It would be an easy plugin to make to close the connection manually.

#2 @DD32
14 years ago

  • Priority changed from highest omg bbq to normal

The question is, What connections, No mention of MySQL there, so it nearly seemed like it could be related to HTTP connections, Else 2.7 wouldnt be specifically causing it.

#3 @jacobsantos
14 years ago

DD32, it is doubtful that it is HTTP connections. I'm a good citizen, so I close the connections when I'm using fsockopen and fopen and even cURL. HTTP should close the connection when it is finished. It doesn't give any handle, so it is not possible to do it manually.

#4 @DD32
14 years ago

I was thinking of the Cron connections, AFAIK, they're not closed?

MySQL though, is a possibility, And allthough PHP should be closing them, Ensuring they're closed would be best i guess.

#5 @ryan
14 years ago

In < 2.7, cron requests do not do an explicit fclose(), IIRC.

#6 @mallyo
14 years ago

thanks for your assistance.

MySQL client version: 4.1.22

#7 @mallyo
14 years ago

here is the first email complaint I received.

this account has recently been showing signs of causing stability problems on the server which appear to be due to mysql usage on the wordpress installation, it does not appear to be closing it's connections which are then hanging and causing problems for the rest of the server.

#8 @mrmist
14 years ago

Not seeing this during normal usage of my 2.6 test or 2.7 test sites. mysql processlist is not full of stale connections, which I'd expect if this was a core problem. Maybe plugin related?

#9 @mallyo
14 years ago


Any advice or suggestions how to fix this?

#10 @ryan
14 years ago

WP uses one non-persistent mysql connection that is shut down when PHP script execution ends. Maybe a plugin is doing extra calls to mysql_connect() or you have a custom wp-db.php that does connection retries.

#11 @mallyo
14 years ago

sorry, I've not modified wp-db.php and only have the mods installed above.

#12 @mallyo
14 years ago


Any further advise or questions?

#13 @mallyo
14 years ago

I'm sorry but I'm still having this problem.

Can anyone suggest a fix please?

13 years ago

Forcefully close mysql connection on shutdown

#14 @vladimir_kolesnikov
13 years ago

  • Keywords has-patch reporter-feedback added

#15 @Denis-de-Bernardy
13 years ago

Based on the plugins that are active on his install, I sincerely doubt the patch will do any good.

I've had a couple of customers with similar issues, which I traced down to extraordinarily long ping lists. Having them shorten it to only a few ping servers fixed the issue.

Just FYI...

#16 @Denis-de-Bernardy
13 years ago

@mallyo: if this is your case, rename the ticket accordingly, do not close it.

#17 @Denis-de-Bernardy
13 years ago

It could also be due to the sitemap generation scripts.

#18 @ryan
13 years ago

  • Milestone 2.8 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Reopen with requested feedback.

Note: See TracTickets for help on using tickets.