question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhandled Error : Process crashed with: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Host"]

See original GitHub issue
const axios = require('axios')

;(async () => {
  const url = "http://www.smun.spb.ru"
  const head_response = await axios.head(url)

  console.log(head_response.headers)
})()
.then(() => { console.log("Success")})
.catch(() => { console.log("Error")})

Throws this exception

Process crashed with: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Host"]
    at validateHeader (_http_outgoing.js:506:11)
    at ClientRequest.setHeader (_http_outgoing.js:510:3)
    at new ClientRequest (_http_client.js:228:12)
    at Object.request (http.js:41:10)
    at RedirectableRequest._performRequest (/home/runner/node_modules/follow-redirects/index.js:158:24)
    at RedirectableRequest._processResponse (/home/runner/node_modules/follow-redirects/index.js:249:10)
    at ClientRequest.RedirectableRequest._onNativeResponse (/home/runner/node_modules/follow-redirects/index.js:39:10)
    at Object.onceWrapper (events.js:272:13)
    at ClientRequest.emit (events.js:180:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:540:21)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Stratecommented, Jan 22, 2020

@chinesedfan the problem is that incorrect server response crashes process, instead of rejecting promise.

0reactions
chinesedfancommented, Feb 15, 2020

Closed by #2689.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid character in header content ["Host"] Postman
I had the same error being reported for any forked or created Postman requests: Error: Invalid character in header content ["Host"].
Read more >
Invalid character in header content [“Host”] Postman - Help
When i try to test api with localhost:[port] it gives the invalid character in header [“Host”] console error. I am using dotnet core...
Read more >
TypeError: Invalid character in header content ["getKeyByValue"]
Hi,. When I'm setting a header in the http out, I get this fatal error. TypeError: Invalid character in header content ["getKeyByValue"].
Read more >
Help resolving Invalid character in header content
Hi, I have a working slack app running as an Azure function using NodeJS. It is posting payloads fine to my channel.
Read more >
Getting Invalid http header / Invalid Data when trying to GET
This GET works when I try it in Postman. But when I run the program, I get the error message below. This is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found