[Python] Pythonanywhere - ping: socket: Operation not permitted

Discussão em 'Python' iniciado por Stack, Julho 24, 2025.

  1. Stack

    Stack Membro Participativo

    Please help. I have a Telegram Bot that ping static IP every 60 seconds, when i start him from Bash Console - it works fine but once a day stops working. I tried to use Always on task but in log file receive 'ping: socket: Operation not permitted'. I have 5USD account, what can i do?

    What i see when run from Bash Console:

    --- 176.102.48.100 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms PING 176.102.48.100 (176.102.48.100) 56(84) bytes of data.
    --- 176.102.48.100 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms PING 176.102.48.100 (176.102.48.100) 56(84) bytes of data. --- 176.102.48.100 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms


    What i see in Always On Task Logs:

    2023-01-12 08:55:34 - Task preparing to start
    Jan 12 09:00:58 ping: socket: Operation not permitted
    Jan 12 09:01:58 ping: socket: Operation not permitted
    Jan 12 09:02:58 ping: socket: Operation not permitted
    Jan 12 09:03:58 ping: socket: Operation not permitted
    Jan 12 09:04:58 ping: socket: Operation not permitted


    My Ping script

    def check_ip_available() -> bool:
    hostname = "IP HERE"
    response = os.system("ping -c 1 " + hostname)
    if response == 0:
    return True

    return False


    Can i fix this? Thanks

    I tried both ways to start my bot but it works only from Bash Console. But Console resets every 24 hours and i need Always On Task

    Continue reading...

Compartilhe esta Página