Tell me why it does not connect from the host server to the database on the VPS server. This script works from my computer, even without the connect_timeout parameter.

#!/usr/bin/python import MySQLdb login = "serj3" password = "12345678" db = MySQLdb.connect(db='fatum', host="хх.хх.хх.хх", user="root", passwd="хххххххх", connect_timeout=150) c = db.cursor() add_gamer = "INSERT INTO accounts(login, password) VALUES (%s,%s) ",(login,password) c.execute(*add_gamer) db.commit() db.close() 

. According to the documentation, 150 is seconds, but it turns around 10 seconds and gives an error 500. They write in the logs that they could not connect, the connection timed out. _mysql_exceptions.OperationalError: (2003, 'Can \' t connect to MySQL server on \ 'xxx.xxx.xxx.xx \' (110 "Connection timed out") ')

    1 answer 1

    Perhaps on the VPS, the database needs data to allow remote connection

    • I am writing that everything works with my computer. - Sergey White
    • @SergeyWhite, the host server may also have a setting that prohibits remote connection, only allows connection to the local database - Sdafs Fasafs
    • found out what the problem was. they did not allow the firewall to remotely connect to another database. thanks for the response - Sergey White