I am using Astro in a dev container via VSCode. I exposed port 4321 in my devcontainer.json file and have run the dev server using astro dev --host. This allows my local browser to see the page successfully on startup. However, when I make changes to the default "Welcome.astro" component I don't see the changes I made to the page. The Dev server shows that it reloaded, but the generated HTML doesn't have my changes.
#dev server not showing changes on update
9 messages · Page 1 of 1 (latest)
Hi @prime jolt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the knowledge sources, here are some steps and considerations for troubleshooting your issue with the Astro dev server not showing changes, even though the server reloads:
-
Dev Server Behavior
Astro’s dev server is designed to watch for file changes and update the site preview automatically. When you edit files in thesrc/directory, the dev server should reflect those changes in your browser without needing a manual restart. If you see the server reloading in the terminal but not in the browser, something is interfering with the hot reload or file watching mechanism Develop and build. -
File Watching in Dev Containers
When running in a dev container (like with VSCode’s Remote - Containers), file watching can sometimes be unreliable due to how file system events are propagated between the host and the container. This is a common issue with many dev servers, not just Astro. The documentation does not provide a direct solution for this scenario, but it’s a known limitation in containerized environments. -
Check for Correct File Save
Ensure that your editor is actually saving the file inside the container’s filesystem. Sometimes, files may appear changed in the editor but are not saved in the correct location or are not triggering the watcher Create your first Astro page. -
Dev Server Flags
You are already using--host, which is correct for exposing the server to your local machine. There are no additional flags in the documentation that would affect hot reloading or file watching in this context CLI Commands.
-
Restart the Dev Server
If the live preview stops working or does not reflect changes, the documentation suggests stopping (Ctrl+C) and restarting the dev server. This can sometimes resolve issues where the watcher has lost track of file changes View a preview of your website. -
Check for Errors
Look for any errors in the terminal where the dev server is running. The server should indicate if it is serving at a different URL or if there are build errors preventing updates Develop and build.
Summary:
The knowledge sources confirm that Astro’s dev server should update the browser preview as you edit files. However, in containerized environments, file watching can be unreliable. The recommended steps are to ensure files are saved correctly, try restarting the dev server, and check for any errors in the terminal. If the problem persists, it may be due to limitations of file watching in your dev container setup, which is not directly addressed in the official documentation.
If you need more advanced troubleshooting, such as adjusting file watcher polling or container settings, the knowledge sources do not provide explicit guidance on this topic.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@prime jolt Kapa.ai is still learning and improving, please let me know how I did by reacting below.
restarting the dev server does reflect my changes. Manual refresh of the page in my browser does not. The file is definitely being saved correctly. There are no errors in the terminal
@hearty mirage restarting the dev server does reflect my changes. Manual refresh of the page in my browser does not. The file is definitely being saved correctly. There are no errors in the terminal
Let me check the knowledge base for you again. One moment! :books:
Thank you for the clarification. Based on the knowledge sources, Astro’s dev server is designed to update the browser preview automatically as you edit files, and a manual browser refresh should also reflect the latest changes if the dev server has reloaded and rebuilt the page Develop and build. If restarting the dev server reflects your changes, but a manual refresh does not, and there are no errors in the terminal, this is not expected behavior according to the official documentation.
The knowledge sources do not provide explicit troubleshooting steps for this specific scenario—where the dev server reloads, but the generated HTML does not update until a full server restart. They confirm that:
- The dev server should reflect changes live as you edit and save files.
- Manual browser refresh should show the latest content if the dev server has reloaded.
- Restarting the dev server is a fallback if live updates stop working View a preview of your website.
However, there is no mention of issues where the dev server reloads but serves stale content until a restart, nor are there documented solutions for this specific problem in the provided sources.