R
Railway9mo ago
Arctic

pythonanywhere

hey guys im running a python file on the pythonanywhere server. This script interacts with my mysql database thats hosted on railway. I keep getting this error: Error while connecting to MySQL 2003 (HY000): Can't connect to MySQL server on 'xxxxxxxxxx' (111) do i need to change something in my railway mysql settings for this to work? thanks in advance
39 Replies
Percy
Percy9mo ago
Project ID: 7153bdf5-ed62-48a4-9967-63355e157c94
Arctic
ArcticOP9mo ago
7153bdf5-ed62-48a4-9967-63355e157c94
Brody
Brody9mo ago
what you have hidden with the X's would be very helpful information
Arctic
ArcticOP9mo ago
oh, its just my railway host name viaduct.proxy.rlwy.net:31243
Brody
Brody9mo ago
thank you, can you connect to the same database locally?
Arctic
ArcticOP9mo ago
yes, locally everything works just fine if more info is required, let me know
Brody
Brody9mo ago
may i ask why not run the file on railway?
Arctic
ArcticOP9mo ago
how would i run a simple python script on railway?
Brody
Brody9mo ago
about the same way you would run any other python related thing on railway
Arctic
ArcticOP9mo ago
i have never done that before, ive created a github repo now and deployed it, but how do i install dependencies and run the main script? i cant access the bash console or something right?
Brody
Brody9mo ago
about the same way you would run any other python related thing on railway.
i cant access the bash console or something right?
no, but i can't see there being a need for that
how do i install dependencies?
provide a requirements.txt file
how do i run the main script?
you can provide a Procfile with something like web: python script.py
Arctic
ArcticOP9mo ago
thank you so much Brody:) gonna try that now
Brody
Brody9mo ago
sounds good! let me know if there are any difficulties
Arctic
ArcticOP9mo ago
great, will do ok ive set everything up and the built has been successful but now that the bot is running im getting alot of errors its spamming this error: raise exc File "/opt/venv/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 330, in _request_wrapper code, payload = await self.do_request( File "/opt/venv/lib/python3.8/site-packages/telegram/request/_httpxrequest.py", line 285, in do_request raise TimedOut from err telegram.error.TimedOut: Timed out this is my procfile: worker: python bot.py
Brody
Brody9mo ago
well that's an unlucky start, you might have landed on a box that telegram has blocked, try to deploy again but with a completely new railway project
Arctic
ArcticOP9mo ago
ive seen the thread about that, gonna try that thanks:) getting the same error:/ il try once more same thing, guess it has to do with something else? File "/opt/venv/lib/python3.8/site-packages/telegram/_bot.py", line 768, in initialize await self.get_me() File "/opt/venv/lib/python3.8/site-packages/telegram/ext/_extbot.py", line 1873, in get_me return await super().get_me( File "/opt/venv/lib/python3.8/site-packages/telegram/_bot.py", line 542, in decorator result = await func(self, *args, **kwargs) File "/opt/venv/lib/python3.8/site-packages/telegram/_bot.py", line 903, in get_me result = await self._post( File "/opt/venv/lib/python3.8/site-packages/telegram/_bot.py", line 630, in _post return await self._do_post( File "/opt/venv/lib/python3.8/site-packages/telegram/ext/_extbot.py", line 347, in _do_post return await super()._do_post( File "/opt/venv/lib/python3.8/site-packages/telegram/_bot.py", line 658, in _do_post return await request.post( File "/opt/venv/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 200, in post result = await self._request_wrapper( File "/opt/venv/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 340, in _request_wrapper raise exc File "/opt/venv/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 330, in _request_wrapper code, payload = await self.do_request( File "/opt/venv/lib/python3.8/site-packages/telegram/request/_httpxrequest.py", line 285, in do_request raise TimedOut from err telegram.error.TimedOut: Timed out
Brody
Brody9mo ago
no, you're probably just landing on the same box
Arctic
ArcticOP9mo ago
hm any idea how i can land on a different one?
Brody
Brody9mo ago
nothing but try different deployments
Arctic
ArcticOP9mo ago
ok so keep doing new projects?
Brody
Brody9mo ago
if youre okay with that are you deploying new projects from the dashboard?
Arctic
ArcticOP9mo ago
yea this doesnt seem to lead anywhere:/ any other ideas? in the thread they posted this: "Yes, that is correct. If you need it, you can delay the startup of the bot until the private netowrking is set up, or handle the timeout error and retry until it succeeds." but i have no idea how to do this 😅
Brody
Brody9mo ago
sleep 3 && python bot.py how are you passing your bot token into your code?
Arctic
ArcticOP9mo ago
through .env file
Brody
Brody9mo ago
you have an .env file in your repo?
Arctic
ArcticOP9mo ago
yep and its working locally
Brody
Brody9mo ago
are you aware that it's not something you should be doing
Arctic
ArcticOP9mo ago
oh, no im not why not is it a security issue?
Brody
Brody9mo ago
secrets in a plaintext file is a terrible idea, and then publishing them to your github is even worse private or not
Arctic
ArcticOP9mo ago
oh really, okay thats good to know
Brody
Brody9mo ago
but while bad practice, I can't see it breaking anything in this case
Arctic
ArcticOP9mo ago
yea thanks anyways will keep this in mind for other projects in the future but yea the sleep thing didnt help either
Brody
Brody9mo ago
might have to continue running the bot on python anywhere then
Arctic
ArcticOP9mo ago
yea okay any idea how to access the mysql database from there?
Brody
Brody9mo ago
make sure you're using all the correct credentials
Arctic
ArcticOP9mo ago
ok man i made a dumb mistake ... i had a console open where the bot was still running under the same bot token and that was messing with the railway version now its working thanks so much for your help ❤️
Brody
Brody9mo ago
that would do it, but in your defense, that was a very deceiving error message, ive done the same, but with the telegram library I use it tells me that another bot is already running
Arctic
ArcticOP9mo ago
yep it didnt say that, only when i checked my local console there i got the "another bot is already running" error and also it seems like all the projects i created the bots were still running when i deleted only the services, had to delete the entire project as additional info for anyone facing similar projects
Brody
Brody9mo ago
good information!
Want results from more Discord servers?
Add your server