Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:01:11+00:00 2026-06-12T10:01:11+00:00

Scenario I am running a very simple server on nodejs: var http = require(http);

  • 0

Scenario

I am running a very simple server on nodejs:

var http = require("http");
var ConnectionsNumber = 0;

function onRequest(request, response)
{
    console.log((new Date).toUTCString() + " - Request received");
    console.log(request.headers);
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Listening\n");
    response.end();
    ConnectionsNumber++;
    console.log('Requests so far: ' + ConnectionsNumber);
}

http.createServer(onRequest).listen(8888);
console.log((new Date).toUTCString() + " - Server started");

But when I start the server and make requests (via Chrome) the server receives two requests at once. Here is the log:

Wed, 03 Oct 2012 16:03:27 GMT - Server started
Wed, 03 Oct 2012 16:03:34 GMT - Request received
{ host: 'localhost:8888',
  connection: 'keep-alive',
  'cache-control': 'max-age=0',
  'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4',
  accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'accept-encoding': 'gzip,deflate,sdch',
  'accept-language': 'it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4',
  'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' }
Requests so far: 1
Wed, 03 Oct 2012 16:03:34 GMT - Request received
{ host: 'localhost:8888',
  connection: 'keep-alive',
  accept: '*/*',
  'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4',
  'accept-encoding': 'gzip,deflate,sdch',
  'accept-language': 'it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4',
  'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' }
Requests so far: 2

Question

What is happening?

Edit

Here is the winner:

var http = require("http");
var ConnectionsNumber = 0;

function onRequest(request, response)
{
    console.log((new Date).toUTCString() + " - Request received");
    console.log(request.url);

    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Listening\n");
    response.end();

    ConnectionsNumber++;
    console.log('Requests so far: ' + ConnectionsNumber);
}

http.createServer(onRequest).listen(8888);
console.log((new Date).toUTCString() + " - Server started");

And the corresponding log:

Wed, 03 Oct 2012 20:00:04 GMT - Server started
Wed, 03 Oct 2012 20:00:14 GMT - Request received
/
Requests so far: 1
Wed, 03 Oct 2012 20:00:14 GMT - Request received
/favicon.ico
Requests so far: 2

That’s all folks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:01:12+00:00Added an answer on June 12, 2026 at 10:01 am

    Chrome requests a favicon by default. That is probably why you are seeing a second request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario I have a bunch of processes running on a server as part of
Scenario: Apache Wicket based web application running on Tomcat server. User opens URL in
I have a scenario which is causing very long running processes and suspect it
I am running the following feature: Scenario: viewing existing images Given I am on
I'm running into a scenario where at random times I am getting Access Denied
I'm running into the classic scenario where, when creating Word COM objects in .NET
Scenario: A client calls WebService A on the LAN. WebService A is running under
Scenario Multiple application servers host web services written in Java, running in SpringSource dm
Here is the scenerio: We have an application running on Webphere Portal Server 6.1
I'm running some tests with Cucumber/Capybara. I've got one scenario where the user goes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.