ivy
ivy

Reputation: 25

ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]

So I was trying out making a bot in Discord and I tried running my discord bot over Gitpod and it was able to run, but when I tried running it on pythonanywhere.com, I get this error:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]

Here is a snippet of my code:

import discord
from discord.ext import commands
import json

with open("credentials.json") as creds:
    creds = json.loads(creds.read())
    TOKEN = creds["TOKEN"]

client = discord.Client()

class Bot(commands.Bot):
    def __init__(self):
        super(Bot, self).__init__(command_prefix="$", case_insensitive=True)
        self.pool = None

bot = Bot()

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user)
    print('------')

# calculate
@bot.command()
async def calculate(ctx):
    await ctx.send("foo")

bot.run(TOKEN)

Any help would be greatly appreciated.

Upvotes: 2

Views: 14073

Answers (1)

Filip
Filip

Reputation: 676

Free accounts on PythonAnywhere can't use the Discord websockets API, but you can use their HTTP-based one. Take a look at the forum post that explains how to do that.

Upvotes: 5

Related Questions