ERR_CONNECTION_TIMED_OUT Express

Created an Express web service which looks like it is deployed correctly

URL: https://url-shortener-arne.onrender.com:10000/

but when I try to reach it it always displays ERR_CONNECTION_TIMED_OUT. Any idea how to fix it?

this is my index code

import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
import { connectDB } from './config/db'
const shortenerRoutes = require('./routes/shortener')

dotenv.config()

const app = express();

const PORT = process.env.PORT ?? 3000;

app.use(cors());
app.use(express.json());

connectDB();

app.get('/', (req: any, res: any) => {
  res.send('Hello, this is the root path!');
});
// Routes
app.use('/api', shortenerRoutes);

app.listen(PORT, () => {
  console.log(`Server is running at ${process.env.DOMAIN_URL}:${PORT}`);
});

SOLVED

Added an environmental variable with PORT = 10000 (default render port).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.