PythonAnywhere - Are sockets allowed?

2k Views Asked by At

I have a beginner PythonAnywhere account, which, the account comparison page notes, have "Access to External Internet Sites: Specific Sites via HTTP(S) Only."

So I know only certain hosts can be accessed through HTTP protocols, but are there restrictions on use of the socket module? In particular, can I set up a Python server using socket?

2

There are 2 best solutions below

0
On

Nope. PythonAnywhere doesn't support the socket module.

0
On

PythonAnywhere dev here. Short answer: you can't run a socket server on PythonAnywhere, no.

Longer answer: the socket module is supported, and from paid accounts you can use it for outbound connections just like you could on your normal machine. On a free account, you could also create a socket connection to the proxy server that handles free accounts' Internet access, and then use the HTTP protocol to request a whitelisted site from it (though that would be hard work, and it would be easier to use requests or something like that).

What you can't do on PythonAnywhere is run a socket server that can be accessed from outside our system.