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 8569419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:19:47+00:00 2026-06-11T18:19:47+00:00

Saw lot ot tutorials, articles and stackoverflow questions about getting the client IP address

  • 0

Saw lot ot tutorials, articles and stackoverflow questions about getting the client IP address from NodeJS.
Almost all of them use this request.header('x-forwarded-for')
My NodeJS v0.8.7 doesnt have that request.header function.

typeof request.header returns undefined

However I have request.headers that is an object containing some info:

{ host: '127.0.0.1:8000',
  connection: 'keep-alive',
  accept: '*/*',
  'user-agent': 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1',
  'accept-encoding': 'gzip,deflate,sdch',
  'accept-language': 'en-US,en;q=0.8',
  'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' }

The host value seemed to be worth of checking out. Running node on localhost obviously returned 127.0.0.1:8000, but then I tried accessing my node.js site from my netbook on the same network, pointing to 192.168.0.13 (my desktop IP in which node is running) and I got 192.168.0.13:8000. So its not giving me the client IP but which IP im using to point to the app.

I tried then request.connection.remoteAddress as it got named over the tutorials I found. Running from localhost gave 127.0.0.1, and from my netbook 192.168.0.12. So it worked! 192.168.0.12 is my netbook IP.
But over the tutorials and questions I found they say that the correct way would be the first one, depending if the proxy is yours or not.

So what would be the right way to do it? and why request.header doesnt exist to me?

  • 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-11T18:19:48+00:00Added an answer on June 11, 2026 at 6:19 pm

    If you’re using express 3, you can do this:

    req.ip
    // => "127.0.0.1"
    

    http://expressjs.com/api.html#req.ip

    If you want other headers, you can use this:

    req.get(field)
    
    req.get('Content-Type');
    // => "text/plain"
    
    req.get('content-type');
    // => "text/plain"
    
    req.get('Something');
    // => undefined
    

    http://expressjs.com/api.html#req.get

    If you’re using plain node, use this:

    request.headers
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read a lot about soft deletes and archive and saw all the
I saw lot of posts in StackOverflow and elsewhere talking about concrete implementation. While
I have saw a lot of them, but all they look not accelerated and
I saw a lot of examples of CopyStream implementation but I have question about
I have been searching all over the internet tonight, saw a lot of solutions
Hy I'm trying to get all the videos from a user and put them
I saw a lot of posts about this pattern, but still don't understand why
ASP.NET MVC 3 introduced DependencyResolver and I saw a lot of articles how cool
I saw a lot of topics about powershell + waiting for process ending, but
I saw a lot of threads and postings about .NET and generating barcodes. A

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.