Telegram bot - mysql connection help pls

Zadeh

New member
Joined
Sep 4, 2023
Messages
1
Telegram bot I buy database from a MySQL server and entered the information into the bot's code. However, I couldn't get it to work in any way. I'm running the bot on Heroku. It connects to other MySQL servers, but it can't connect to the MySQL server I buy the database from. It seems like I'm having trouble with the host. The error code I'm getting is as follows: mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on 'localhost:3306'.

I've tried this on my Ubuntu server as well, but I'm getting the same error there too. Note that I've tried the MySQL server's IP, domain, and everything else.

DB_HOST = 'localhost'
DB_NAME = 'st35380_userdbtelegram'
DB_USER = ''
DB_PASSWORD = ''

# Create a MySQL connection
db = mysql.connector.connect(
host=DB_HOST,
database=DB_NAME,
user=DB_USER,
password=DB_PASSWORD,
)
 
Back
Top