本地Windows环境下Neo4j执行LOAD CSV查询遇WebSocket连接失败求助
Hey there, let's troubleshoot that WebSocket connection failure you're facing when running your LOAD CSV query on Windows. I’ve dealt with this exact issue a few times, so here are the most reliable fixes to try out:
确认Neo4j服务正在运行
First things first: make sure your Neo4j database instance is up and running. If you’re using Neo4j Desktop, check that your database card shows "Running" at the top. If you're using the command line, navigate to your Neo4j installation'sbinfolder and run:neo4j.bat statusIf it’s not running, start it with:
neo4j.bat startOr just hit the "Start" button in Neo4j Desktop if that’s your setup.
检查CSV文件的位置与权限
Your query usesfile:///Test.csv, which means Neo4j expects the file in its dedicatedimportdirectory. On Windows, this is usually:- For Neo4j Desktop:
C:\Users\<YourUsername>\.neo4j\import - For a standalone installation:
<Neo4jInstallDir>\import
Move yourTest.csvinto this folder to avoid path-related errors. Also, right-click the file, go to Properties > Security, and make sure the user running Neo4j (or your Windows account) has read permissions for the file.
- For Neo4j Desktop:
调整Neo4j的网络配置
WebSocket issues often tie back to Neo4j’s connector settings. Open yourneo4j.conffile (found in your Neo4j installation'sconffolder) and verify these parameters:dbms.connector.bolt.enabled=true:确保驱动WebSocket连接的Bolt连接器处于开启状态。dbms.connector.bolt.listen_address=:7687:检查7687端口是否被其他程序占用,在命令提示符中运行以下命令查看:
如果端口被占用,要么关闭占用端口的程序,要么将监听地址改为其他端口(比如netstat -ano | findstr :7687:7688),之后重启Neo4j服务生效。- 如果你处于测试环境,可以临时设置
dbms.security.auth_enabled=false来排除认证问题(记得生产环境要重新开启!)。
排除客户端/浏览器干扰
如果你在Neo4j Browser中运行查询,试试刷新页面或者切换到其他浏览器(比如从Edge换成Chrome)。浏览器扩展或缓存数据有时会阻断WebSocket连接。另外,要确认Neo4j Browser中的连接URL和你的Bolt设置匹配(默认是bolt://localhost:7687)。先用简单测试排查问题
运行一个基础查询,看看WebSocket问题是否只出现在LOAD CSV上:CREATE (test:TestNode {id: 1, name: "Test"})如果这个查询也抛出同样的错误,说明问题出在基础连接上,和CSV导入无关;如果查询正常,那可能是你的CSV文件有问题(比如格式错误、编码异常或者数据量过大导致超时)。可以先把CSV精简到2-3行再测试,缩小问题范围。
内容的提问来源于stack exchange,提问作者Zehra Ansari

