Python Forum
Connection timed out error when connecting to SQL server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connection timed out error when connecting to SQL server
#1
Hello all,
I am trying to connect to MariaDB on my LINUX server from my PC using the Python mysql.connector.
I can connect to the server via ssh so I know the IP address (10.0.0.117) is correct.
When I log into the server and run the same script (with "localhost" as the hostname) it works fine.
However, when I run the script from my PC, it gives the following error:

Error:
2003: Can't connect to MySQL server on '10.0.0.117:3306; (116 Connection timed out)
Below is the Python script. Any help would be appreciated.

from tkinter import *
import mysql.connector
from tkinter import messagebox

hostname = "10.0.0.117"
username = "username"
password = "password"

try:
		mydb = mysql.connector.connect(
	        host=hostname,
	        user=username,
	        passwd=password
	        )
		if mydb.is_connected():
		    dbinfo = mydb.get_server_info()
		    msg_text = "Connected to SQL database "+dbinfo
		    messagebox.showinfo("Information",msg_text)
except mysql.connector.Error as e:
		msg_text = "Cannot connect to SQL database "+str(e)
		messagebox.showerror("Error",msg_text)
Reply
#2
Did you open the port on your router for your database?
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
https://www.digitalocean.com/community/t...s-to-mysql
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 714 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  connecting to FTPS server help tfboy 2 2,624 Feb-23-2023, 10:31 AM
Last Post: tfboy
  Issues with "connection timed out" duckredbeard 0 1,448 Dec-31-2022, 10:46 PM
Last Post: duckredbeard
  Server Folder Error : WinError5 Access Denied fioranosnake 1 1,114 Jun-21-2022, 11:11 PM
Last Post: Larz60+
  Mysql error message: Lost connection to MySQL server during query tomtom 6 15,958 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  pysql connection to cloud server database times out Pedroski55 9 4,699 Oct-11-2021, 10:34 PM
Last Post: Pedroski55
  Serial connection connection issue Joni_Engr 15 8,014 Aug-30-2021, 04:46 PM
Last Post: deanhystad
Shocked Help for COM server implementation ("Unspecified error" on Dispatch()) Alfalfa 2 3,451 Jul-25-2021, 01:36 AM
Last Post: Alfalfa
  How to take the tar backup files form remote server to local server sivareddy 0 1,893 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  500 internal server error Nitil 1 2,875 May-01-2021, 06:16 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020