Render is a hosting service: a company that runs your code on their computers, all day, at a public URL anyone can visit. It has a free tier, and that's all we'll use in this class.
GitHub Pages has been hosting our sites all semester. It's a static host: when a browser asks for a file, GitHub sends that file back exactly as it is. It never runs any of our code itself.
A Node server is different. It's a program that has to keep running somewhere, waiting for requests and deciding what to send back. GitHub Pages can't do that. Render (like Heroku, Railway, or Fly.io, which you may have heard of) gives you a computer that runs your server for you, using the commands you tell it to.
csc336-fall2026 folder. Make a new folder inside it called
render-test.
server.jsrender-test, make a file called server.js with this code. It uses
only Node's built-in http, so there's nothing to install.
import http from "http";
// Render tells our server which port to use with the PORT environment variable.
// On your own computer, PORT isn't set, so we use 3000 instead.
let port = process.env.PORT || 3000;
// This function runs once for every request that comes in.
let server = http.createServer((req, res) => {
// On Render, this shows up in the Logs page (Render's version of the terminal).
console.log(req.method + " " + req.url);
// This runs fresh for every request, so the time changes every time you refresh.
// A static host like GitHub Pages can't do this: it only sends files.
let now = new Date();
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Hello from my server! The server's clock says " + now.toString());
});
server.listen(port, () => {
console.log("Server running on port " + port);
});
package.jsonrender-test, make a file called package.json:
{
"name": "render-test",
"type": "module"
}
"type": "module" is what lets us use import. Render also needs this
file to exist, or its npm install step will fail.
cd render-test
node server.js
Visit http://localhost:3000. You should see
the hello message, and the time should change when you refresh. Press Ctrl+C to
stop the server.
render-test folder is there with both files in it.
https://github.com/YOUR-GITHUB-USERNAME/csc336-fall2026
Then click Connect. This works because your repo is public. (The other option,
Git Provider, links your GitHub account to Render. That works too, but you don't need it.)
| Field | What to put |
|---|---|
| Name | Anything, like yourname-render-test. It becomes part of your URL. |
| Language | Node |
| Branch | main |
| Region | Anything (the default is fine) |
| Root Directory | render-test (see below) |
| Build Command | npm install |
| Start Command | node server.js |
| Instance Type | Free |
render-test folder. Root Directory tells
Render "treat this folder as the whole project." Render runs the build and start commands
inside that folder, which is why the start command is just node server.js
and not node render-test/server.js. If your server is in a different folder, put
that folder's path here instead (for example a08/server). If you leave it blank,
Render uses the top of your repo. You can change it later in your service's
Settings page, under Build & Deploy.
npm install downloads
whatever is listed in package.json (nothing yet, but once you use Express, this is
what installs it). Start Command is what actually runs your server, exactly like
typing it in your own terminal.
console.log message,
Server running on port 10000, and then a message saying your service is live.
(10000 is the port Render picked and put in process.env.PORT.)
https://yourname-render-test.onrender.com
Click it. You should see your hello message, coming from your server, running on Render's
computer. Refresh it a few times and watch the time change.
GET / line shows up. This is your server's terminal now.
https://YOUR-GITHUB-USERNAME.github.io/csc336-fall2026/render-test/server.js.
GitHub Pages just shows you the file's text. The time never changes, because nothing ran it.
Because we connected with a public repo URL, Render doesn't notice when you push new code. After you commit and push a change, go to your service's page in Render and click Manual Deploy, then Deploy latest commit.
fs.writeFileSync), those changes disappear whenever the server restarts, redeploys,
or falls asleep. It goes back to whatever is in GitHub. Saving data for real is what databases
are for.
Check the deploy log first. The error is usually near the bottom.
| You see | It probably means |
|---|---|
Could not read package.json |
Root Directory is wrong, or package.json wasn't pushed |
Cannot find module .../server.js |
Start Command or Root Directory doesn't match where server.js is (check
spelling and capitalization) |
Cannot use import statement outside a module |
package.json is missing "type": "module" |
| Your latest change isn't showing up | Did you push it? Then click Manual Deploy |
| The page takes forever to load | It was asleep. Give it a minute |