Hi all,
I have a problem with mysql connections. After about 28000-29000
connections, I get a "Can't connect to MySQL server on '127.0.0.1'" error.
I have made a small program which generates the error
"""
import MySQLdb
for i in range(30000):
if not i % 100:
print i
db = MySQLdb.connect(host='127.0.0.1', user='me',passwd='mypassword')
c = db.cursor()
c.close()
db.close()
"""
This is the error after making about 28200 connections:
'''
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/tmp/python-12448vuu", line 7, in ?
db = MySQLdb.connect(host='127.0.0.1', user='me', passwd='mypassword')
File "/usr/local/lib/python2.3/site-packages/MySQLdb/__init__.py", line
64, in Connect
return apply(Connection, args, kwargs)
File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py",
line
116, in __init__
self._make_connection(args, kwargs2)
File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py",
line
41, in _make_connection
apply(super(ConnectionBase, self).__init__, args, kwargs)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server
on
'127.0.0.1' (99)")
'''
Does anybody know how to solve this issue?
System: Suse 8.1, mysql 4.0.14, mysqldb 1.0.1, python2.3
Thanks very much.....
Fedor 4 4342
On Thu, 10 Mar 2005 14:07:44 +0100, fedor <f.*****@gmail.com> declaimed
the following in comp.lang.python: I have a problem with mysql connections. After about 28000-29000 connections, I get a "Can't connect to MySQL server on '127.0.0.1'" error.
<snip>
This is the error after making about 28200 connections: ''' Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/tmp/python-12448vuu", line 7, in ? db = MySQLdb.connect(host='127.0.0.1', user='me', passwd='mypassword') File "/usr/local/lib/python2.3/site-packages/MySQLdb/__init__.py", line 64, in Connect return apply(Connection, args, kwargs) File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py", line 116, in __init__ self._make_connection(args, kwargs2) File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py", line 41, in _make_connection apply(super(ConnectionBase, self).__init__, args, kwargs) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (99)") '''
Does anybody know how to solve this issue?
Off hand, I suspect you've run out of unused TCP sockets. Each
connect results in your task allocating a port, and possibly MySQL
allocating a fresh socket to handle the connection that it finds on its
assigned port.
I seem to recall reading somewhere that sockets normally have a
delay factor on reuse, which may be all the way up to two minutes before
a freed socket can be reused.
Check documentation on REUSEADDR options...
-- ================================================== ============ < wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < ================================================== ============ < Home Page: <http://www.dm.net/~wulfraed/> < Overflow Page: <http://wlfraed.home.netcom.com/> <
fedor wrote: Hi all,
I have a problem with mysql connections. After about 28000-29000 connections, I get a "Can't connect to MySQL server on '127.0.0.1'" error.
I have made a small program which generates the error
""" import MySQLdb
for i in range(30000): if not i % 100: print i db = MySQLdb.connect(host='127.0.0.1', user='me',passwd='mypassword') c = db.cursor() c.close() db.close() """ This is the error after making about 28200 connections: ''' Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/tmp/python-12448vuu", line 7, in ? db = MySQLdb.connect(host='127.0.0.1', user='me', passwd='mypassword') File "/usr/local/lib/python2.3/site-packages/MySQLdb/__init__.py", line 64, in Connect return apply(Connection, args, kwargs) File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py", line 116, in __init__ self._make_connection(args, kwargs2) File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py", line 41, in _make_connection apply(super(ConnectionBase, self).__init__, args, kwargs) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (99)") '''
Does anybody know how to solve this issue?
I'm not sure this is something you'll see in Real Life (tm). Try running
an overnight test to see whether sleeping for 100 milliseconds between
connections makes the problem go away. If it does, then you are just
running our of available TCP ports.
There's a delay period after a TCP connection is closed and before the
same port number can be re-used by another local process.
If you run your test as it is currently written and after it fails run
netstat -an
you should see a large number of connections in the TIME_WAIT state. If
so then you probably have nothing much to worry about.
regards
Steve '127.0.0.1' (99)") '''
Does anybody know how to solve this issue?
Off hand, I suspect you've run out of unused TCP sockets. Each connect results in your task allocating a port, and possibly MySQL allocating a fresh socket to handle the connection that it finds on its assigned port.
That was it.
Also changing '127.0.0.1' to 'localhost' solves the problem.
Thanks.
Fedor
On Fri, 11 Mar 2005 21:23:08 +0100, fedor <no****@here.com> declaimed
the following in comp.lang.python: Also changing '127.0.0.1' to 'localhost' solves the problem.
Heh... Maybe the name lookup is delaying the rest of the
function just enough for some ports to be recycled <G>
-- ================================================== ============ < wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < ================================================== ============ < Home Page: <http://www.dm.net/~wulfraed/> < Overflow Page: <http://wlfraed.home.netcom.com/> < This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Harrison |
last post by:
Hi all, got a problem combinging mx and MySQLdb, when I build and install both for my Python2.1 install on a Solaris 9 box I can import mx fine, but importing MySQLdb causing python to core dump.
...
|
by: Peter Nikolaidis |
last post by:
Greetings,
I am attempting to get MySQLdb 0.9.2 installed on Mac OS 10.2 with a
Fink distribution of Python 2.2.2. I have seen only a few posts on the
subject, some of them relate to...
|
by: Phillip |
last post by:
Hi.
I hate the way one has to jump through countless hoops to put data in a
db and get it out again. The straightforward MySQLdb Interface
requireing this SQL stuff being a point in case (against...
|
by: Steve |
last post by:
Darwin steve.local 8.3.0 Darwin Kernel Version 8.3.0: Mon Oct 3
20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC Power Macintosh
powerpc
MacOSX 10.4.3
mysql Ver 14.7 Distrib 4.1.14, for...
|
by: Yi Xing |
last post by:
Hi,
I met the following error when I tried to install MySQLdb. I had no
problem installing numarray, Numeric, Rpy, etc. Does anyone know
what's the problem? Thanks!
running install
running...
|
by: Gerard M |
last post by:
Hi guys I have a big problem with this wrapper im using Ubuntu 7.04
and I want to install python-MySQLdb, I used synaptics and it is
installed, but when I try to do
and I get this error:
...
|
by: geert |
last post by:
Hi all,
I have a mac mini running maocosx 10.5 leopard I want to deploy a
django project on. My backend is MySQL, and I have it running as a 64-
bit app. Of course, apache2 is also running as...
|
by: AdamGr |
last post by:
I am currently trying to convert a program I just wrote to application form, on the Mac. I'm using py2app to accomplish this, and everything works fine up until the last stage; when I try to complete...
|
by: Lawrence D'Oliveiro |
last post by:
In message <mailman.109.1216158151.922.python-list@python.org>, Cyril Bazin
wrote:
What's the error message? This should be in Apache's error_log file.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |