feedback
feedback copied to clipboard
[Bug]: Connection refused to express server.
What happened?
I tried to use RapidAPI to my localhost express server, but it didn't work. I think it's because of express, and this is why.
- I tried on google and github, just to make sure that my rapidAPI didn't broke. They gave me web page without css/js.
- I tried on my react/spring app running on localhost.
- React app gave me noscript(which I expected).
- Spring app gave me json I expected.
- I tried on my express app hosted on heroku.
- get request to index page gave me web page without css/js.
- post request gave me json I expected.
- I tried on demo express app, and it gave me 'Connection refused'.
Steps to reproduce?
Code below is the code I used for testing.
- node.js version is 16.17.0(LTS).
- express version is 4.18.1.
// server.js
const express = require('express');
const app = express();
const PORT = 8080;
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.get('/', (req, res) => {
res.json({hello: 'world'})
});
app.listen(PORT, () => {
console.log(`Express server is now running in port ${PORT}`);
});
// node server.js
VS Code version
version 1.71
Extension version
v1.5.0
Relevant log output
No response
I had the same problem, instead of request to http://localhost:8080 try http://[::1]:8080, or change the host in app.listen(), by default if host is omitted NodeJS will use Ipv6, docs.