a year ago
Hi, all I get is a "Application failed to respond" when I get the endpoint, what should I do?
11 Replies
a year ago
It's the port, its always already in use?!
a year ago
Logs:> node server.js
App listening on port: 7342
node:events:495
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::7342
at Server.setupListenHandle [as _listen2] (node:net:1817:16)
at listenInCluster (node:net:1865:12)
at Server.listen (node:net:1953:7)
at Function.listen (/app/node_modules/express/lib/application.js:635:24)
at file:///app/server.js:67:5
at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:106:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1844:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 7342
}my server:import express from "express";
import { google } from "googleapis";
import { readFile } from "fs/promises";
// Load environment variables from a .env file, if available
//dotenv.config();
const app = express();
// Use the PORT environment variable, or default to port 3000 if it's not set
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`App listening on port: ${port}`);
});
const SCOPES = ["https://www.googleapis.com/auth/webmasters.readonly"];
const keyFile = "combine-rank-tracker-990f8fef77e4.json";
....what am I doing wrong?
a year ago
This is it, the whole code, import express from 'express';
import { google } from 'googleapis';
import { readFile } from 'fs/promises';
const app = express();
const PORT = process.env.PORT || 3000;
const SCOPES = ['https://www.googleapis.com/auth/webmasters.readonly'];
const keyFile = 'combine-rank-tracker-990f8fef77e4.json';
const auth = new google.auth.GoogleAuth({
keyFile,
scopes: SCOPES,
});
const searchconsole = google.webmasters({
version: 'v3',
auth,
});
app.get('/check-index', async (req, res) => {
const { url } = req.query;
if (!url) {
return res.status(400).send('Missing url parameter');
}
try {
const siteUrl = 'https://www.intuitiva.pt';
const request = {
siteUrl,
requestBody: {
startDate: '2023-01-01', // Adjust this date as needed
endDate: new Date().toISOString().split('T')[0],
dimensions: ['page'],
dimensionFilterGroups: [{
filters: [{
dimension: 'page',
operator: 'equals',
expression: url,
}],
}],
},
};
const response = await searchconsole.searchanalytics.query(request);
const isIndexed = response.data.rows && response.data.rows.length > 0;
const status = isIndexed ? 'indexed' : 'not indexed';
res.json({ url, status });
} catch (error) {
res.status(500).send(`Error checking index status: ${error.message}`);
}
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
a year ago
Might have found the mistake, should be PORT not port on the app.listen...
Status changed to Solved railway[bot] • 12 months ago
a year ago
still not working, still saying ReferenceError: port is not defined, I've pushed the update 3 times already, via the CLIA, railway up, not sure why it's still giving me this error? Is it not process.env.PORT set automatically by Railway? Do I have to define this variable? Is there some tag / placeholder for dynamic ports?
a year ago
This must be some sort of docker cache thing?
a year ago
I started a new project and now it worked, it was the cache thing on docker, how do I clear the cache on railway up? Is there any flag to force the build and discard previous?
a year ago
if AI is not alucinating, railway up --force should work?
a year ago
The AI is hallucinating, railway up
has no --force
flag, either way this was not a cache issue, you had something missconfigured on the other service.