Forums

RabbitMQ connects on local but not on production PythonAnywhere

I have tested it multiple times and I'm using the same code on local and on prod. It works on local but on prod I get the following error: 2023-03-28 03:42:58,955: Pika version 1.3.1 connecting to ('34.197.186.156', 5672) 2023-03-28 03:42:58,956: Socket failed to connect: <socket.socket fd=20, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.0.0.34', 59288)>; error=111 (Connection refused) 2023-03-28 03:42:58,956: TCP Connection attempt failed: ConnectionRefusedError(111, 'Connection refused'); dest=(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('34.197.186.156', 5672)) 2023-03-28 03:42:58,957: AMQPConnector - reporting failure: AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused') 2023-03-28 03:42:58,957: AMQP connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused'); first exception - None. 2023-03-28 03:42:58,957: AMQPConnectionWorkflow - reporting failure: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused'); first exception - None 2023-03-28 03:42:58,957: Connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused'); first exception - None 2023-03-28 03:42:58,958: Error in _create_connection(). Traceback (most recent call last): File "/home/fryingpannn/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection raise self._reap_last_connection_workflow_error(error) pika.exceptions.AMQPConnectionError It seems CloudAMQP which is used to host my RabbitMQ instance refuses my connection. The hostname is woodpecker.rmq.cloudamqp.com. I am using the free tier of PythonAnywhere. Is it because the hostname isn't whitelisted? I am able to telnet 34.197.186.156 5672, but in the bash console on Python Anywhere it's connection refused.

Thanks.

Free accounts have limited internet access. See https://www.pythonanywhere.com/whitelist/