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
Project ID:
7153bdf5-ed62-48a4-9967-63355e157c94
7153bdf5-ed62-48a4-9967-63355e157c94
what you have hidden with the X's would be very helpful information
oh, its just my railway host name
viaduct.proxy.rlwy.net:31243
thank you, can you connect to the same database locally?
yes, locally everything works just fine
if more info is required, let me know
may i ask why not run the file on railway?
how would i run a simple python script on railway?
about the same way you would run any other python related thing on railway
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?
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
thank you so much Brody:) gonna try that now
sounds good! let me know if there are any difficulties
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
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
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
no, you're probably just landing on the same box
hm any idea how i can land on a different one?
nothing but try different deployments
ok so keep doing new projects?
if youre okay with that
are you deploying new projects from the dashboard?
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 😅
sleep 3 && python bot.py
how are you passing your bot token into your code?through .env file
you have an .env file in your repo?
yep
and its working locally
are you aware that it's not something you should be doing
oh, no im not
why not
is it a security issue?
secrets in a plaintext file is a terrible idea, and then publishing them to your github is even worse
private or not
oh really, okay thats good to know
but while bad practice, I can't see it breaking anything in this case
yea thanks anyways will keep this in mind for other projects in the future
but yea the sleep thing didnt help either
might have to continue running the bot on python anywhere then
yea okay any idea how to access the mysql database from there?
make sure you're using all the correct credentials
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 ❤️
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
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
good information!