nodejs connectio error #10887
Unanswered
JustSirDave
asked this question in
General
Replies: 1 comment
-
Eventually tried port 9000 and it worked |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
const http = require('http')
const fs = require('fs')
const homePage = fs.readFileSync('index.html')
const aboutPage = fs.readFileSync('about.html')
const contactPage = fs.readFileSync('contact.html')
const notFoundPage = fs.readFileSync('notfound.html')
const server = http.createServer((req, res) =>{
if(req.url === '/about')
res.end(aboutPage))
else if(req.url === '/contact')
res.end(contactPage)
else if(req.url === '/')
res.end(homePage)
else {
res.writeHead(404)
res.end(notFoundPage)
}
console.log(req.url)
res.end('Hello Node.js')
})
server.listen(3000)
returned error connecting to localhost
i even tried using another port. same error...can anyone help???
Beta Was this translation helpful? Give feedback.
All reactions