MySQL / PHP error: [2002] Only one use of each socket address is allowed (protocol / network address / port)

I could not find a solution to this issue already in stackoverflow, most of the other related issues are related to the fact that Apache does not start first and does not receive this error. My problem is that after starting apache some of my users connected to our php / mysql site will get this error:

PHP Warning:  mysql_connect() [function.mysql-connect]:
[2002] Only one usage of each socket address (protocol/network address/port)
is normally permitted.

This seems completely random, and when I track my workflows for Apache, there are usually many free workers available to accept new connections / requests.

My site is running Windows XP SP3, Xampp 1.7.7, Quad Core, 4 gigabytes of RAM, 1 TB HD, Specifications for php / mysql:

Apache / 2.2.21 (Win32) mod_ssl / 2.2.21 OpenSSL / 1.0.0e PHP / 5.3.8 mod_perl / 2.0.4 Perl / v5.10.1

Any help on what I have to change in any of my configurations to do this would be greatly appreciated. I looked at google and even on Xampp forums, but most people experience this problem before starting Apache, but Apache works fine for me when users experience this error.

+7
source share
5 answers

The error is actually not from MySQL, but from Windows itself :

When the connection is closed, on the side that closes the connection, tuple 5 {Protocol, Local IP, Local port, Remote IP, Remote port} goes into TIME_WAIT state for 240 seconds by default.

In this case, the protocol is fixed - TCP

IP, IP PORT . , .

, 1024-5000. , 4000 . 4 - 16 - , 4 . .

, . , , . ?

:

  1. .
  2. , , TIME_WAIT, .
  3. , , , regedit.

!

. Visual Studio, :

, , , . Winsock API SO_REUSEADDR ( .NET Socket), TcpListener .

, MySQL Apache SO_REUSEADDR.

, keepalive . , Windows .

+8

Windows REGISTRY, ,

regedit :

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

4 DWORD :

TcpTimedWaitDelay
REG_DWORD: 0000001e (hex)

MaxUserPort
REG_DWORD: 0000fffe (hex)

TcpNumConnections
REG_DWORD: 00fffffe (hex)

TcpMaxDataRetransmissions
REG_DWORD: 00000005 (hex)

:

enter image description here

+8

Laravel. , , Windows. Linux . , , MySQL "localhost" "127.0.0.1".

+2

.

CurrPorts http://www.nirsoft.net/utils/cports.html - , , . , netstat, Windows , , CurrPorts .

Currports as administrator β†’ /, , β†’ . -

  • Currports.
  • β†’ β†’ service.msc β†’ ( ).
  • TaskManager.

, , .

0

FWIW, (Windows XP). Mac (OS X).

, MySQLi.

. : http://php.net/mysqli.persistconns

, /, .

-1

All Articles