craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

Unable to use site URL to connect to Craft nitro #450

Closed wallythewebdev closed 2 years ago

wallythewebdev commented 2 years ago

Description

I cannot seem to use the SITE URL that I selected during the craft set up to access the craft website. OR (maybe the issue is) - Nitro has not configured the host files to recognize the IP address of the site as the SITE URL

TLDR:

Q) is there a way to find out what IP address the nitro site is running on - like nitro open <sitename> ?

After posting the question I managed to find the answer to the Site IP address question:

By running: nitro bridge it will output the the IP address of the websites running on your machine From docs: https://craftcms.com/docs/nitro/2.x/local-sharing.html

Q) is there a location to find out the sites details - or any errors to be addressed in its setup? Q) can you download an earlier version of craft, or does the version of craft downloaded by Nitro match the version of PHP you set the project up with - so if you decide to run php 7.2 - Nitro downloads the version of Craft suited for PHP 7.2?

Steps to reproduce

  1. Run nitro create <sitename>
  2. Input required details - and have conformation of successful install
  3. run nitro craft setup & complete
  4. Try to acsess the site address: https://tutorial.nitro/ or http://tutorial.nitro/
  5. presented with This site can’t be reached

image

--

Any debugging steps would be really helpful (im very keen to use Nitro for local dev, but the set up has been bumpy) - thanks

TomDeSmet commented 2 years ago

I have the same issue on Mac. Just installed Nitro (running on alternative port 8080 for http). I can connect to the database, all containers are running but I cannot get to the site.

I have Valet installed too, maybe that has something to do with it?

wallythewebdev commented 2 years ago

@TomDeSmet -

I found (from my above)

By running: nitro bridge it will output the the IP address of the websites running on your machine From docs: https://craftcms.com/docs/nitro/2.x/local-sharing.html

If you see your craft website here and IP address - then you can use the IP address instead of the site name to access it.

TomDeSmet commented 2 years ago

I already tried that but it doesn't work for me because I get the following error when trying to go to the IP url. I obscured some data here of course.

connecting to the-craft.nitro
Bridge server listening on http://XXX.XXX.X.XXX:8000
2022/02/08 17:55:42  /
2022/02/08 17:55:42 http: proxy error: dial tcp 127.0.0.1:80: connect: connection refused
wallythewebdev commented 2 years ago

@TomDeSmet This is kinda out of my depth - it has not been a easy set up on my end (using windows)....

But, check everything is running as required I guess??

Is the DB running? Check Docker

image

Command: nitro ls will list out the status as well:

image

If they have stopped you can start the process by using nitro start

image

TomDeSmet commented 2 years ago

Everything’s running fine. Not getting any errors of any meaning in the containers. I already stopped valet and restarted all containers. Nothing…

wallythewebdev commented 2 years ago

@TomDeSmet what output do you get when you run the command craft bridge?

Should be:

image

What error do you get once you try and go to that IP address that is listed - if it is listed?

TomDeSmet commented 2 years ago

@wallythewebdev as stated in a previous post above:

connecting to mywebsite.nitro
Bridge server listening on http://XXX.XXX.X.XXX:8000
2022/02/08 17:55:42  /
2022/02/08 17:55:42 http: proxy error: dial tcp 127.0.0.1:80: connect: connection refused
jasonmccallister commented 2 years ago

@TomDeSmet

I have Valet installed too, maybe that has something to do with it?

Valet and Nitro will conflict, if you try mysite.nitro:8080 it should resolve?

@wallythewebdev

By running: nitro bridge it will output the the IP address of the websites running on your machine From docs: https://craftcms.com/docs/nitro/2.x/local-sharing.html

The bridge command looks at your local machine IP (your laptop) and allows you to share a site on the network with another device (e.g. iPad or iPhone). Nitro runs everything in localhost/127.0.0.1 so its not public to people on your network without the bridge command.

wallythewebdev commented 2 years ago

Hi @jasonmccallister - Thanks for the reply.

Thanks for mentioning the localhost/127.0.0.1 address - however this does not connect to the site. Also, the IP address nitro bridge provides is now showing an error:

connecting to tutorial.nitro
Bridge server listening on http://XXXXXXXX:8000
2022/02/08 19:03:47  /
2022/02/08 19:03:47 http: proxy error: dial tcp: lookup tutorial.nitro on XXXXXXXXXX: no such host

Do you have any suggestions for how to debug the above (it worked yesterday after a fresh install).

Thanks

TomDeSmet commented 2 years ago

I already tried that and strange enough, now it works with the added port. Is there a way to split valet and nitro or should I uninstall valet?

TomDeSmet commented 2 years ago

@wallythewebdev Check your host file, it should contain:

#<nitro>
127.0.0.1 tutorial.nitro
#</nitro>
wallythewebdev commented 2 years ago

@TomDeSmet

Host file does not contain that: I manually added it and can access it from http://tutorial.nitro/ (which is great so thanks).

But this does make me wonder @jasonmccallister @TomDeSmet - is there a command missing to allow Nitro to update the host files & does this mean that Nitro needs to edit host files when it is started nitro start - Which if it is, is fine, I just need to make sure that it can if that is the case.

any suggestions?

TomDeSmet commented 2 years ago

My host file was edited when I added my project. So it's definitely possible. It prompts for your password when adding/creating a site to modify your host file. And there's also the nitro hosts command.

jasonmccallister commented 2 years ago

@wallythewebdev There is a technical limitation on Windows that does not allow us to edit the hosts file. This page has more details on how to use Nitro with Windows https://craftcms.com/docs/nitro/2.x/windows.html

Glad you got it sorted!

wallythewebdev commented 2 years ago

@TomDeSmet - Thanks for the suggestion - running nitro apply got it working by printing out the required host file path that needed to be added:

image

@jasonmccallister Ah that all makes way more sense now - thanks for the advice and pointing to the Docs.

Can I make a small UI suggestion for windows users regarding the docs, I know writing docs is not an easy task, and there is allot of information packed into them, but given the slightly different install process for windows and caveats (regarding limitations) - it might be best to separate out the docs into separate pages for Windows and Mac/Linux installs of Nitro.

One of the issues I came across was trying to piece together info from different doc pages instead of it being in one controlled flow of information that follows the install process.

Just some UX feedback, not a criticism, and I'm really grateful for the help you've given here.

jasonmccallister commented 2 years ago

Thank you and that is probably a good suggestion @wallythewebdev, I'm going to ping @mattstein and see if this is something he wants to add/improve on the documentation.

If we have this working, I think we are ok to close this issue out?

wallythewebdev commented 2 years ago

@jasonmccallister Yeah great and thanks for your help and @TomDeSmet as well -

if you want input on writing the docs - happy to help :)

mattstein commented 2 years ago

Thanks @wallythewebdev!

If I’m understanding right, you’re saying it’d be easier to navigate Nitro + Windows docs if they were visually separated by that OS. I get that—there were enough Windows caveats that we separated out the install instructions by OS, and added that Development with Nitro and WSL2 page so we could (hopefully) call those things out clearly.

The ultimate goal, and the reason I’m hesitant to segregate the docs by OS, is to rejoin the docs flow for daily usage that shouldn’t vary significantly from one OS to another.

If there are more nuanced issues you had finding bits of information that were there I’d like to understand and address them, but I’m not sure about splitting the docs out by operating system. Let me know if I’m missing your point or if the unified-docs goal seems out of touch with reality! :)

wallythewebdev commented 2 years ago

Hi @mattstein Thanks for the reply.

I'll spend a little time over the next coming days review the doc flow for installation and see if there are any instances I can pin point specifically.

I can see why you'd be hesitant to separate the docs into different pages for different installs, but I think some of the information stored on https://craftcms.com/docs/nitro/2.x/windows.html could be included during the install process and not on a separate page which has led to me scrabbling for answers (I'm also fully aware that this could just be a case of me being a bad user, so these are only suggestions). Also, on that note, since there is already a specific page for the Caveats of Windows, it might serve the user to have this page extended with common windows debugging solutions.

The one nuance that drove me loopy was not knowing that I'd need to update the host files (this made me second guess the whole install process). Annoyingly (and this might be me being a bad user), I did notice that it had prompted me to do so after the craft create X & 'craft apply' - but this information was lost so maybe more hierarchy can be given to it.

image

this was compounded by the details regarding the host file being mixed in with Certificates, I think separating these two out into two points and emphasizing when you'd be prompted to edit the host files would help (maybe?):

image

Thanks again for touching base, I really apricate you taking the time and fully acknowledge that I might be totally wrong on the points above.