ConnectionRefusedError: [Errno 111] Connection refused


I’m trying to connect to Anvil via uplink from and I’m getting this error:

Connecting to wss://
Traceback (most recent call last):
File “/home/madmaxx/”, line 11, in
File “/home/madmaxx/.local/lib/python3.8/site-packages/anvil/”, line 259, in connect
File “/home/madmaxx/.local/lib/python3.8/site-packages/anvil/”, line 246, in _get_connection
raise e
File “/home/madmaxx/.local/lib/python3.8/site-packages/anvil/”, line 243, in _get_connection
File “/home/madmaxx/.local/lib/python3.8/site-packages/ws4py/client/”, line 217, in connect
File “/usr/lib/python3.8/”, line 1342, in connect
self._real_connect(addr, False)
File “/usr/lib/python3.8/”, line 1329, in _real_connect
ConnectionRefusedError: [Errno 111] Connection refused

Is there any restriction? When I try to copy&paste the same code to google colab, it works as expected.

Ok after some attempts I’ve been able to setup a virtualenv with anvil-uplink installed and I can confirm what is saying.
I get the same error.
Pythonanywhere doesn’t allow ping nor traceroute but a good old

(anvil_uplink_test) 14:12 ~/anvil_uplink_test $ telnet


telnet: Unable to connect to remote host: Connection refused
(anvil_uplink_test) 14:13 ~/anvil_uplink_test $  

It really looks like AWS is refusing connection from PythonAnyWhere.

I think we stop here and leave word to Anvil Team.

Welcome to Anvil!

Are you on a free account with PythonAnywhere?

I seem to remember (but can’t find a definitive) that you cannot connect to external servers unless they use http on the free account.

I might be wrong, but it’s worth checking.

If you go here :
and search for “Can I use an external MySQL service” on that page, the section the answer is in implies http connectivity only. This probably means uplink won’t work on a free account.

First paragraph of this pretty much confirms it :

I see is whitelisted in
And Anvil’s server resolves to

So, is it possible that the problem is due to the fact that:

Free users are restricted to HTTP/HTTPS only

while anvil.server.connect uses websocks?

Yeah, that’s kinda what I was getting at.

1 Like

Thank you all for your replies. It’s sad.

I wanted to try the scheduled script run that is available in the free version of pythonanywhere as I wanted to use it for my son’s football club info scrape (as there is no rss feed or such) and I don’t want to pay 40 bucks for that (even though anvil is a great tool indeed)…

Could you ealborate a little what you’re trying to accomplish?
May be an approach can be found, compatible with all the restrictions.


I’m trying to scrape a site on regular basis which is not possible with anvil free service.

Could you please check their reply?

Ok I leave the word for the “proxy-aware” stuff to Anvil Team.
But I want to stress that you have alternatives to Uplinking if you need to send some data from a script running in pythonanywhere to you Anvil’s App.
Uplink, if available, is obviously the easiest and preferred way.
But you could set up an HTTP API in your App and call it from your pythonanywhere’s code.
Worse, yet workable, you could set up an email processor in your App and send emails to it from pythonanywhere’s code.
It’s Anvil. You always have options.
Options that are fun to explore.