Port 8080 is already in use
adubasava
TRIALOP

2 years ago

Hi, I constantly get "Application failed to respond" and "Port 8080 is already in use container event container died" (actually any port I tried is in use). App works locally just fine. I have this problem after deploying Postgres db (it seems to work fine as well when I start app locally).

My app.js:

require("dotenv").config();

const createError = require("http-errors");

const express = require("express");

const path = require("path");

const indexRouter = require("./routes/index");

const app = express();

// view engine setup

app.set("views", path.join(__dirname, "views"));

app.set("view engine", "ejs");

app.use(express.urlencoded({ extended: true }));

app.use(express.static(path.join(__dirname, "public")));

app.use("/", indexRouter);

// catch 404 and forward to error handler

app.use(function (req, res, next) {

next(createError(404));

});

// error handler

app.use(function (err, req, res, next) {

res.locals.message = err.message;

res.locals.error = req.app.get("env") === "development" ? err : {};

// render the error page

res.status(err.status || 500);

res.render("error");

});

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

app.listen(PORT, () => console.log(Express app listening on port ${PORT}!));

module.exports = app;

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

2 Replies

2 years ago

You are trying to listen on port 8080 twice, please review your code so that you can remove this bug.


adubasava
TRIALOP

2 years ago

Thank you, fixed


Status changed to Solved brody almost 2 years ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...