1

I have a simple node.js server running on port 8080 with socket.io with the code from here What is an example of the simplest possible Socket.io example?.

When I connect with curl, it works fine:

curl -vk http://www.example.com:8080 * Connected to www.example.com (123.456.789.123) port 8080 (#0)

When I browse using Chrome 70.0.3538.110 on Mac to http://www.example.com:8080 it just keeps loading until I get ERR_CONNECTION_TIMED_OUT. I get the same result in Safari.

However, when I browse directly to the IP like this http://123.456.789.123:8080 it works right away.

Why can this be? The domain points to the right IP, and apparently it works in curl, and also wget. Is there any header missing or something else that browsers need?

I found something on a differentabout accept header, that might be related:

The reason it doesn't work from your browser is probably that it sends an accept header something like:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,\*/\*;q=0.8

Whereas curl (and presumably the Chrome extension) asks for:

Accept: \*/\*

However, the index.js has res.writeHead(200, {'Content-Type': 'text/html'}); so I think it should send a proper header. Also it works in the browser with the IP, so it might not be related to this.

How can I fix this?

Niclas
  • 1,362
  • 1
  • 11
  • 24
  • Have you tried completely restarting your browser, some cache dns requests – COLBY BROOKS Dec 05 '18 at 16:23
  • Also are you sending the cURL from the server itself or from a different machine – COLBY BROOKS Dec 05 '18 at 16:25
  • It’s both from the same machine and the domain works on another site on the same hostname which is on port 80 and 443 with apache. So it shouldn’t be a dns issue. I haven’t restarted my computer though, but since the other port works it seems if it’s something the browser is waiting for? – Niclas Dec 05 '18 at 17:12
  • Then it sounds like you dont have the port 8080 forwarded – COLBY BROOKS Dec 05 '18 at 17:16
  • It works in the browser if I connect with the IP instead of the domain name, and it works with curl on the domain name, all with port 8080, so it shouldn’t be that. Thanks for the ideas though. :) – Niclas Dec 05 '18 at 17:35
  • are you able to ping the hostname? – COLBY BROOKS Dec 05 '18 at 17:41
  • Also have to you tried connecting from another computer – COLBY BROOKS Dec 05 '18 at 17:42
  • I forgot to add that I have apache on the same server on port 80 and 443. Might it be listening and somehow snapping up connections in the browser and not curl..? – Niclas Dec 05 '18 at 18:29

0 Answers0