Failed to open TCP connection to localhost:3036 #89
-
Description 📖Hello, I've been trying to migrate a Rails app from webpacker to vite-rails, and while everything works with the I unfortunately could not reproduce this error on a new project so it is likely to be an issue with something else on my app that's not letting Rails connect to the vite dev server for some reason. But other connections are working fine (like to While this may not be an issue with vite_ruby/vite_rails itself, would anyone know what could possibly be going wrong with my setup? I have tried not running most extra middleware and most things from the initializers folders that's not default by Rails, also with no success. Reproduction 🐞Vite Ruby InfoRun
Logs 📜Vite dev server itself seems to run just fine with seemingly nothing wrong on logs If not providing a reproduction: OutputRun
Rails error logs
vite.config.ts and vite.jsonimport { resolve } from 'path'
import { defineConfig } from 'vite'
import RubyPlugin from 'vite-plugin-ruby'
export default defineConfig({
plugins: [RubyPlugin()],
resolve: {
alias: {
'@': resolve(__dirname, 'app/javascript/entrypoints'),
'@assets': resolve(__dirname, 'app/assets')
}
}
}) {
"all": {
"sourceCodeDir": "app/javascript",
"watchAdditionalPaths": []
},
"development": {
"publicOutputDir": "vite-dev",
"port": 3036,
"autoBuild": true, // I have also tried using not using autoBuild
"devServerConnectTimeout": 3 // I have tried a lot of different timeouts, and using the default one, with no success
},
"test": {
"autoBuild": true,
"publicOutputDir": "vite-test"
}
} Screenshots 📷Provide console or browser screenshots of the problem. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Hi John Victor! Nothing unusual in the config, except that it might be better to be explicit with the alias: {
'@/': `${resolve(__dirname, 'app/javascript/entrypoints')}/`, Otherwise it could interfere with certain imports such as Based on the Rails error logs, it seems that the Vite dev server is not reachable. You'll want to verify this from a Rails console, by using
What is the response if you |
Beta Was this translation helpful? Give feedback.
-
The problem is related with a recent change in Vite, which affects systems where Configuring "development": {
"autoBuild": true,
"host": "127.0.0.1",
"publicOutputDir": "vite-dev",
"port": 3036
}, I will evaluate changing the default from |
Beta Was this translation helpful? Give feedback.
The problem is related with a recent change in Vite, which affects systems where
localhost
defaults to::1
(IPv6).Configuring
host
explicitly to127.0.0.1
should fix the problem.I will evaluate changing the default from
localhost
to127.0.0.1
since at the moment Vite performs that conversion and causes this issue.