dennis dennis - 1 year ago 106
Python Question

Pyapns Fault 500: 'Connection to the APNS server could not be made

Hi i am trying to get my django app to send a push notification to an iOS device running the iOS app of this service. I am trying to use pyapns to send the notifications. But I cant get it to connect to the apple push notification server.

The service are mostly done this is the last thing that a what to get to work before I step out of beta. You can visit to read about the app.

Here is the log:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/pyapns/", line 75, in wrapper return func(*a, **kw) File "/usr/local/lib/python2.7/dist-packages/pyapns/", line 67, in wrapper return func(*a, **kw) File "/usr/local/lib/python2.7/dist-packages/pyapns/", line 97, in notify return _xmlrpc_thread(*f_args) File "/usr/local/lib/python2.7/dist-packages/pyapns/", line 127, in _xmlrpc_thread errback(e) File "/usr/local/lib/python2.7/dist-packages/pyapns/", line 65, in errback_wrapper errback(e) # not an instance of UnknownAppID - nothing we can do here File "/usr/local/lib/python2.7/dist-packages/pyapns/", line 55, in errback raise e xmlrpclib.Fault:

Has anybody had this problem? Can it be same thing with the .pem file? or the setup of the ubuntu-server? Can i have forgotten to open some ports in the router?


I did a test to se if the ports for apns is open. I did telnet 2195 and got
telnet 2195
Connected to
Escape character is '^]'.

I do think that the server and router are setup correct.

Answer Source

I had the same problem - it's frustrating, because it can make the connection, the .pem file is likely improperly formatted.

Follow this fantastic step-by-step set of directions to generate the correct final .pem file:

Also, set passwords when you're exporting the cert and key from Keychain - I know it says you can do without, but I found setting the password to something random on export from Keychain, then following the final openssl rsa ... step to remove said password before concatenating the files helped fix the problems I was having.

I can't speak to an absolute certainty, but for me, it was the .pem files, which generated the exact error messages you're receiving above.

The final .pem file is text and should be formatted a little something like this (note that the info here is randomly generated and I repeated lines a lot):

Hope this helps :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download