This content originally appeared on Level Up Coding - Medium and was authored by Hayk Simonyan

Introduction
In this article, we’re going to deploy a Node.js application to Fly.io in 3 easy steps. Fly.io is a Hosting Platform very similar to Heroku and it is very easy to deploy an app using their CLI.
They have free allowances and if your app doesn’t exceed these limits that you see here you can use their services for free.
Free Allowances
Resources included for free on all plans:
- Up to 3 shared-cpu-1x 256mb VMs
- 3GB persistent volume storage (total)
- 160GB outbound data transfer
Additional resources are billed at the usage-based pricing detailed below.
Step 1: Install flyctl
Open up the application which you want to deploy, if you just want to follow along, here’s my simple Node.js app for demonstrating the deployment.
The first thing we need to do for deploying our app is to install the flyctl, it’s a CLI for managing apps on Fly.io
- Mac OS: If you’re on a Mac OS and you have brew installed, you can use this command to install the flyctl
brew install flyctl
Otherwise, there’s a script that you need to run to install it
curl -L https://fly.io/install.sh | sh - Linux: For Linux users, you need to run this script
curl -L https://fly.io/install.sh | sh - Windows: On Windows run the Powershell install script
iwr https://fly.io/install.ps1 -useb | iex
Step 2: Signup/Login to Fly
The next step is to sign up or log in to Fly.io. If you already have an account use this command to log in from the terminal
flyctl auth login
Otherwise use the signup command to signup and login
flyctl auth signup
I don’t have an account yet so I will use the signup command to open one. Type flyctl auth signup in your terminal and use GitHub for signing up.

Once you sign up, it will ask you for card details, although you can choose to try it for free without providing a credit card it will be required for deploying your app so it is better to provide a credit card here. It won’t charge you at all if you don’t exceed their free allowance limits.
Step 3: Deploy
After you signed up and provided card info or logged in if you had an account already the last step is to deploy your app using flyctl CLI.
Before you do that, you have to set your internal port to 8080 because it is set to 8080 in the fly.toml file generated by the CLI
So update the port to 8080 and run the deploy command.
flyctl launch
Scanning source code
Detected a Dockerfile app
? Choose an app name (leave blank to generate one):
? Choose a region for deployment: > Miami, Florida (US) (mia)
? Would you like to set up a Postgresql database now? No
? Would you like to set up an Upstash Redis database now? No
? Would you like to deploy now? Yes
Deploying
...
- If you have a Dockerfile it will automatically detect it, if you don’t it will detect the Node.js app and start the deployment
- Next, it asks for an app name, leave this empty and it will generate one
- Choose the region where you want to deploy, whichever is closest to your users
- It asks if you want to set up a Postgresql or Redis database — I will choose No
- And would you like to deploy now? Yes
1 desired, 1 placed, 1 healthy, 0 unhealthy [health checks: 1 total, 1 passing]
--> v1 deployed successfully
Verifying the deployment
To verify that it worked, go to your dashboard. Select the app that you just deployed and open up the link provided under Hostname.




And our application is successfully up and running
Also, you might have environmental variables in your code, these can be added here under the secrets tab in your dashboard.

Summary
That’s all it takes to deploy your app to Fly.io, for more complex apps it might require some additional steps, but the process is the same and you can already start deploying using this guide.
Resources
Deploy a Node App
Log in to Fly
Install flyctl
Fly.io Pricing
Common issues with Fly.io
Troubleshooting your Deployment
🔔 Thanks for reading and follow for more deployment guides
Deploy Node.js App to Fly.io was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Hayk Simonyan
Hayk Simonyan | Sciencx (2022-12-19T15:47:04+00:00) Deploy Node.js App to Fly.io. Retrieved from https://www.scien.cx/2022/12/19/deploy-node-js-app-to-fly-io/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.