Has anyone been able to connect to a managed mySql instance from a Cloudflare worker?

I’m testing the possibility to connect to a Digital Ocean managed mySql instance from a Cloudflare Worker. Cloudflare provides a mySql driver for Workers, but reading the docs I understood that in order for it to work, you need to setup a Cloudflare tunnel, and that the server running mySql needs to run cloudflared in order to securely access the tunnel. Did I understand correclty? Has anyone faced this problem before, and how did you solve it?


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.

Bobby Iliev
Site Moderator
Site Moderator badge
May 29, 2023

Hi there,

Cloudflare recently announced connect() which is a new API for creating TCP sockets from Cloudflare Workers. The full announcement post can be found here:

As far as I can tell from that announcement post, they’re aiming for the adding two popular MySQL drivers, mysql and mysql2, to work on Workers soon, with more to follow.

I’ve also been looking into a similar setup but for Postgres, however, the complexity of the old approach has always kept me reluctant of trying it. This will enormously simplify the whole setup!

Hope that this helps!



Try DigitalOcean for free

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

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

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

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
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