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.

npm start use hostname instead of localhost on Linux

See original GitHub issue

My laptop uses openSUSE Linux with hostname “Guos-Kudu”. When I created a react app and run npm start, it opens http://guos-kudu:3000 in browser. When I visit http://localhost:3000 it cannot be accessed.

Some HTTP API only allows localhost to access. Or the API administrator only enabled localhost in OAuth configuration. In this situation, a non-standard URL will have many troubles.

Even when I changed the hostname to localhost or remove it, react-scripts still looks for http://guos-kudu:3000 instead of localhost. Have no idea what caused this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Timercommented, Aug 14, 2017

The HOST variable is probably set in your env. Try to unset it in your terminal session.

If that works, create a .env.local file which contains the following:

HOST=localhost

You can now run npm start without worrying about unsetting HOST.


To achieve the default CRA behavior, use 0.0.0.0 instead of localhost.

1reaction
Timercommented, Aug 14, 2017

You might want to check your ~/.bashrc or similar (~/.profile, ~/.bash_profile, ~/.bash_profile, ~/.login, etc).

Read more comments on GitHub >

github_iconTop Results From Across the Web

React npm start 127.0.0.1 instead of localhost on windows
So i am trying to launch my react application using 127.0.0.1 instead of localhost. Here is what i tried: in scripts i put...
Read more >
NodeJS/ReactJS: Change HOST AND Port Number
If you need the app to run on some port, assign an environment variable named PORT to the desired port number. Here, the...
Read more >
NPM Run Serve is not defaulting to localhost - Vue Forum
I have been working on a project for about 3 weeks and npm run serve would always serve up App running at: -...
Read more >
Vue CLI: Using a custom domain | Web Development Blog
Vue CLI defaults to a localhost URL. This quick change allows a custom domain to be used instead. ... npm run serve. The...
Read more >
webpack-dev-server - npm
Start using webpack-dev-server in your project by running `npm i ... Tells clients connected to devServer to use the provided hostname.
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