server How To Hostchevron-right window Frameworksfeather NestJSPractical guide to host NestJS applications on Discloud.
π§ Introduction
This step-by-step guide shows how to prepare, configure, and deploy a NestJS application on Discloud.
The process involves building your TypeScript code into the dist folder and running the compiled JavaScript on port 8080. NestJS apps are straightforward to deploy because the framework handles routing, dependency injection, and module organization automatically.
π Requirements
triangle-exclamation
Port 8080 is mandatory β applications must listen on this port.
π§± Local prerequisites
Before continuing, you will need:
Node.js installed on your machine.
A NestJS project created (e.g. nest new my-app).
A Discloud account with a configured subdomain .
Optionally: Git , VSCode , and/or the Discloud CLI to make the workflow easier.
If you are not yet familiar with the local environment, check:
node-js NodeJS chevron-right π§Ή Preparing project files
Before compressing your project into a .zip, create a .discloudignore file in the project root to exclude unnecessary files and folders from the upload:
π§ TypeScript Configuration β tsconfig.build.json
Ensure your tsconfig.build.json (or tsconfig.json) is set to output to the dist folder. Here's a typical configuration:
triangle-exclamation
It is important that compilerOptions.outDir is set to "dist", as Discloud will look for your compiled app there.
π Main entry point β src/main.ts
Ensure your src/main.ts listens on port 8080 and accepts the port from environment variables. Here's a typical setup:
triangle-exclamation
Port 8080 is mandatory. Even if you set PORT in your .env file, it must be 8080.
Bind to 0.0.0.0 (not localhost) so external traffic can reach your app.
π¦ package.json β recommended scripts
Inside your package.json , ensure the build and start scripts are correctly defined:
βοΈ discloud.config β example
Here's a typical configuration for a NestJS app:
For detailed information about each configuration parameter and all available options, refer to the complete guide:
gear discloud.config chevron-right circle-exclamation
Make sure to adjust the ID field to match your registered subdomain from the Discloud dashboard.
π§ͺ Testing locally (production build)
Before uploading to Discloud, verify your app builds and runs correctly:
Build the project locally:
This generates the dist folder with compiled JavaScript.
Test the production build:
Check that the server starts and responds to requests (e.g., via curl http://localhost:8080).
Stop the server and proceed to deployment.
π Environment variables
In NestJS, environment variables are typically accessed via process.env:
Common patterns include DATABASE_URL, API_KEY, REDIS_URL, etc.
Example in a service:
ποΈ Recommended final project structure
A typical NestJS project structure for Discloud might look like:
π Deploying to Discloud
You can deploy your NestJS app using any of the supported methods.
table-columns Dashboard chevron-right robot Discord Bot chevron-right plug Visual Studio Code chevron-right terminal CLI chevron-right π οΈ Troubleshooting (common errors)
App does not open / wrong port
Check if NestJS is listening on port 8080 (process.env.PORT || 8080 in main.ts).
Confirm that your account has the correct plan for websites/APIs.
Make sure you followed the subdomain guide before deploying.
Run locally: npm run build and fix any errors before uploading.
Check that all dependencies are listed in package.json.
Errors when starting ( START )
Verify that the start script is correct.
Follow the Discloud logs to see the exact error message.