Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript React Basics First Steps in React Create a React Element

Jill Lopez
Jill Lopez
405 Points

I can't get my local server to run

I followed the instructions from this site (as recommended): https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server#Running_a_simple_local_HTTP_server.

I cd into the project folder that I am in "o:\Coding\Projects\scoreboard\scoreboard>" and use the prompt "python -m http.server". When I open localhost:8080 on the browser, it says "This site cannot be reached."

4 Answers

Gabbie Metheny
Gabbie Metheny
33,778 Points

Another student posted here about using http-live-server, installed through npm. It has very few downloads, though, and I'd recommend something that's been vetted. I'm using http-server because I'd already installed it in the past for other treehouse courses. You install it globally through npm (npm install -g http-server), and then in the root of your project, all you do is run http-server in your console. You'll get a console message telling you what port your site is running on, for me it's http://127.0.0.1:8080. The only difference for how it's working for me vs. how Guil's server works in the videos is that I have to hard reload every time I make changes (on Chrome in Windows, with dev tools open, right click on the refresh icon, select 'Hard Reload', or just press Ctrl+Shift+R). Hope that helps!

Thanks. This worked for me. Weird he doesn't mention how to do this in the video...

Zack Jackson
Zack Jackson
30,220 Points

James Almeida He mentioned it briefly, but just kinda left it to you to follow the teacher's notes and hope for the best. In the followup course he uses the create-react-app cli which has webpack functionality and does all of this automatically.

I still use live-server a lot with projects where I don't really want to set up webpack or gulp. Super handy with the live reloading.

Zack Jackson
Zack Jackson
30,220 Points

Just posted a response in an earlier video for how I'm going about this with Node.js rather than with python. Link at the bottom.

You can run it globally or set up your project folder with npm init and then set live-server up as a devDependency and a npm script.

live-server has been around for 2 years and has several hundred thousand downloads per month. It also automatically watches and auto reloads the page which is awesome.

Hope this helps.

https://teamtreehouse.com/community/alternative-liveserver-setup

This also worked for me. Thanks!

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

When you did the python -V what did you get?

You might need to run python3 -m http.server - often python is 2.7 while python3 is 3.x

You should get something like - on my desktop it uses port 8000 as the default:

Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/)
Nickolas Fuentes
Nickolas Fuentes
14,016 Points

If people also have another port running something.

You can try this

python3 -m http.server 7800

and it will give you another port to run it on. Also download the React Developer Tools!@