Question

My telegram bot won't respond when running it on Digital Ocean droplet but works fine when I run it locally

I’ve created a telegram bot that works perfectly fine when I run it on my local machine. AKA you can go into telegram and normally interact with the bot when running locally. However, I take the same steps to run the bot on a digital ocean droplet (Ubuntu) and the bot simply does not respond when trying to interact with it in Telegram. Does anybody know the issue here?

Thank you.

I uploaded the relevant files to my Digital Ocean Droplet (AKA Ubuntu Instance) and installed NodeJS and NPM and ran ‘npm install’ and ‘npm start’ as I would on my local machine with no success.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
June 17, 2023

Hey @27f435659dc64d2d877d490c5579ba,

On what port are you accessing your Telegram bot? Additionally, what does no success mean, how are you trying to connect to it?

Here are general things you can try to resolve the issue:

  1. Port Forwarding/Security Group Settings:

    Check whether the ports that your application uses are open and correctly forwarded in your Digital Ocean Droplet. This can be verified in the security group settings of your droplet.

  2. Node.js Server not Listening on Correct IP/Port:

    Ensure that your Node.js application is set to listen on the correct IP (0.0.0.0 for all interfaces) and the correct port.

  3. Environment Variables:

    If your bot uses environment variables, you should set them in the droplet as well. You can use dotenv package to manage them.

  4. Firewall:

    There might be firewall rules that are preventing your bot from accessing the internet. You can use ufw or iptables to manage these rules on your Ubuntu Droplet.

  5. Error logs:

    Check your bot’s logs for any error messages. If your application crashed and restarted, logs will help you understand what happened.

Having said that, I do believe you are accessing the bot on the wrong port.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel